runShell issue with some shell command

Hello
I received my new Yun toy and it works perfectly.
However I do not understand all the subtleties of "runShell" method.
When I try the following command: p.runShellCommand("ifconfig wlan0") , I get the answer no problem with p.avaiable ()> 0 ...
I would do the same thing with the command "iwlist wlan0" in order to catch some info about wireless, but no answer with this command.
Note that both commands works fine via ssh .

All suggestions are welcome.
Charles

I tried on my Yun, the command:

iwlist wlan0

it gives:

iwlist: unknown command `wlan0' (check 'iwlist --help').

the correct command is iwlist scan

Note that with the Process class you can only read stdout (the standard output stream of the process) but NOT the stderr (standard error stream).
Usually error messages are sent to stderr and this is the reason why you didn't catch the output of "iwlist wlan0" (because the error message goes through stderr).

If you want to catch also stderr you can redirect stdout to stderr stderr to stdout using some shell pipe-lining for example:

iwlist wlan0 2>&1

The 2>&1 tells the shell to redirect stderr (2) to stdout (1). Note that this is a shell command, because is the shell that reads the command "2>&1" and do the pipe-lining accordingly not iwlist, so you can use this trick only with runShellCommand(...).

Thank you for your good advice.
I try with p.runShellCommand ("iwconfig wlan0 2>&1") and now I receive all information about my WiFi connection.
It's even better than I expected. :slight_smile: