0

I am using Raspbian and attempting to run a very simple cmd using python with the popen function. I am very new to linux and python

from subprocess import Popen, PIPE po = Popen(['airmon-ng', 'start wlan0 10'], stdin=PIPE, stdout=PIPE, stderr=PIPE) proc = Popen(args, stdout=PIPE, stderr=PIPE) out, err = proc.communicate() out 

returns

'\n\nusage: airmon-ng <start|stop|check> <interface> [channel or frequency]\n\n' 

The error msg returned can be created outside of the popen function when running only airmon-ng without parameters, which makes me believe that popen is not forwarding the args correctly.

1 Answer 1

4

You need to separate comamnd line arguments correctly; start, wlan0, 10 should be separated command line arguments:

proc = Popen(['airmon-ng', 'start', 'wlan0', '10'], stdin=PIPE, stdout=PIPE, stderr=PIPE) out, err = proc.communicate() print(out) 

The way in the question is like invoking the command as follow in the shell:

airmon-ng 'start wlan0 10' 

which is different from:

airmon-ng start wlan0 10 
Sign up to request clarification or add additional context in comments.

3 Comments

note that the whole point of passing a list of parameters is that you've already split them up :)
@Eevee, Sorry, I don't understand what you mean.
directed at the asker — when you use the shell, it just sees the single string "airmon-ng start wlan0 10" and now needs to split it on whitespace etc. using a list (a data structure) ought to mean you've already done that work.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.