rhavin
rhavin

Reputation: 1689

Getting iwconfig output in fields

I just did an iwconfig 2>/dev/null | hd and an echo $(iwconfig 2>/dev/null) | hd

Both outputs have no clear separation between fields and inner-field spaces… it's all spaces -.^

The man-page didnt bring up any way to set iwconfig's field-separator, so i read the sourcecode and there is none, all is done by concatenating sprintf's. I've seen a script that froze hell will some awk's just to get some values and that expected the accesspoint at iwconfig | awk 'Access point:/ {print $6}' and as i had to change that for my system to $4 i wonder if gathering all infomation, stuffing it into a clumpsy output, parsing that linewise and regexing thru the lines really is the proper way to do it … is there an alternative to iwconfig that yields the same information as hash with usefull separated fields, names and values?

Upvotes: 1

Views: 1834

Answers (2)

anoopjohn
anoopjohn

Reputation: 518

You could get the access point mac address with

iwconfig 2>&1 | sed -n -e 's/^.*Access Point: //p'

Upvotes: 1

srd
srd

Reputation: 1267

From the shell , awk or sed may be the only solution. But if you are writing the program in C, you can use the ioctl commands that iwconfig is actually using to print the info you see.

You might also want to give iw a try. iwconifg is being replaced by iw.

Upvotes: 1

Related Questions