1

I would like to log the wireless signal quality and the last number of the IP-address to a text file or an IoT website. Is it possible to extract both in python and/or bash with a simple one-liner?

signal-quality: 90
ip-address: 93

EDIT: The os is the latest rasbian, if that matters.

  • I found out that ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{split($1,A,"."); print A[4]}' gives you the last number of the IP address. But ` iwconfig wlan0 | grep 'Link Quality='| awk '{split($1,A,"/"); print A[1]}' ` is not working. – Markus Sep 21 '15 at 15:38
  • post the output of iwconfig wlan0... it will be easier to grep the part you need. :) – Hastur Sep 21 '15 at 16:17
  • You can simplify the 1st expression ifconfig eth | awk '{if ($1=="inet") {split($2,A,"."); print A[4]}}' . – Hastur Sep 21 '15 at 16:23
0

You can try those 2 lines

ifconfig wlan0 | awk '{if ($1=="inet") {split($2,A,"."); print A[4]}}' 

iwconfig wlan0 | awk '{if ($1=="Link"){split($2,A,"/");print A[1]}}'

if you do not like Quality=90 as output you can pipe the second command in a sed

iwconfig wlan0 | awk....  | sed 's/Quality=//g'
0

Ok, i figured it out. You can log last IP-number, Link/Signal Quality with these three one-liner

ifconfig  | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{split($1,A,"."); print A[4]}' >> ~/logs/iplog
iwconfig wlan0 | grep 'Quality='| cut -d= -f2 | awk '{split($1,A,"/"); print A[1]}' >> ~/logs/linklog
iwconfig wlan0 | grep 'level='| cut -d= -f2 | awk '{split($1,A,"/"); print A[1]}' >> ~/logs/signallog

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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