The python script runs this command:
return_code = call("iw wlan0 scan | sed -e 's#(on wlan# (on wlan#g' | awk -f scan.awk > scan.txt", shell=True)
I want to proceed in my code only if the command goes well. But the return_code is always "0", even when the command fails.
More precisely the failure is represented by
command failed: Device or resource busy (-16)
How can I "capture" this message and avoid that the program continues? If there's the "command failed" error, I want to repeat the shell command but I don't know how to do that.
check_outputyou can see whether the error message contains the failure message – BlackBear Apr 18 '16 at 13:32iw wlan0 scan | sed -e 's#(on wlan# (on wlan#g' | awk -f scan.awk > scan.txt; echo $?– Danilo Muñoz Apr 18 '16 at 13:54return_code = call('mkfifo pipe && iw wlan0 scan > pipe', shell=True)The problem is that this will block until you read from the pipe, which means you need threads. Which means you need to pass the status of the threaded call across a thread boundary. I leave that as an exercise to someone else. – Andrea Reina Apr 18 '16 at 15:29