58

I'm doing a headless setup, where we use the Pis in field work (tracking movement of seals via camera in the Cape Cod area), and so we can only monitor it headless, without a separate display (to save on power).
In order to have the Pis get time, I need them to connect to my colleague's iPhones (which are operating as hotspots), and use ntpd to get time from the internet.
However, I haven't yet figured out what the command is to query the WiFi network name, to confirm that it is connected to the right network - is there one?

2
  • 2
    Your job sounds awesome! Where can I learn more about your work?
    – user40144
    Jan 19, 2016 at 15:07
  • 1
    Our lab website: runstadlerlab.mit.edu :D Personal website: ericmajinglong.com
    – ericmjl
    Jan 19, 2016 at 20:41

3 Answers 3

78

iwgetid will give you the SSID

0
31

Try iwconfig:

user@host:~ $ iwconfig
wlan0     unassociated  Nickname:"<WIFI@REALTEK>"
          Mode:Managed  Frequency=2.412 GHz  Access Point: Not-Associated
          Sensitivity:0/0
          Retry:off   RTS thr:off   Fragment thr:off
          Power Management:off
          Link Quality:0  Signal level:0  Noise level:0
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0
-1

You can use this code to check the IP assigned to the RPi:

t="$(ifconfig wlan0 | awk '/inet addr/{print substr($2,6)}')"
echo $t
w=${#t}
echo $w
2
  • It wasn't asked for the IP address.
    – Ingo
    Jul 22, 2020 at 16:55
  • That code does not work on Raspian/RaspiOS Buster. The awk fails to match the output from ifconfig.
    – Dougie
    Jul 22, 2020 at 21:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.