Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ifconfig & iwconfig

Status
Not open for further replies.

fdservices

IS-IT--Management
Mar 10, 2005
52
FR
OK I'm stupid but - this code:

set if_iswireless [eval [concat exec sudo ifconfig]]

sets the variable to the result of the command ifconfig

but this code:

set if_iswireless [eval [concat exec sudo iwconfig]]

throws an error.

Help!!!!
 
Right off the bat, I don't think you need concat in either case. That said, it certainly isn't causing your problem as I gather the first command works and the second one doesn't, right?

I think it's a LINUX problem rather than Tcl. I assume that you can execute sudo iwconfig from a console, right? If not, that certainly explains why Tcl can't either. Try executing exec sudo iwconfig from a Tcl shell. Then, maybe set er [catch [exec sudo iwconfig]] and see what's returned.

_________________
Bob Rashkin
 
Hi, thanks for the reply.

There seems to be something strange about the way Linux handles iwconfig. Although it appears to be the same as ifconfig, I think that iwconfig, without any arguments, looks up each interface and then executes one each one separately. So the command "iwconfig" returns three answers on my PC, one for each interface. tcl picks up the first response and assigns it to the variable, the second two cause the error.

The answer to the problem was to find the interfaces first with "ifconfig -a" and then execute iwconfig on each one in turn - "iwconfig eth0".

Incidentally I use the eval [concat [ exec ... ]] to overcome problems trying to exec long commands with arguments, which sometimes seem to occur in tcl. Although it may or may not be necessary in all cases, it is easier to just do it to avoid the problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top