I want to run hcitool lescan --duplicates & hcidump -R
using Popen. However Popen does not seem to consider the & (the way it works in bash scripting) and gives error as "lescan: too many arguments"
Am I doing something incorrect
Asked
Active
Viewed 94 times
0

Benjamin J.
- 1,239
- 1
- 15
- 28

user9022502
- 45
- 3
-
What language are you using? Is it neccessary for you to use `popen()`? – Benjamin J. Jan 29 '18 at 19:58
-
I am using python and I need Popen to call the that command as I am parsing the output received by running that command. – user9022502 Jan 29 '18 at 20:31
-
Maybe a duplicate of https://stackoverflow.com/questions/1196074/how-to-start-a-background-process-in-python – Benjamin J. Jan 30 '18 at 17:23
1 Answers
0
Popen
does not interpret shell metacharacters like &
by default. So, you need to pass shell=True
to get it to work. Note that if you're including strings from external sources (e.g. user's files, or user input), then this can be dangerous.
See the frequently used arguments section of the documentation for details.

jpaugh
- 6,634
- 4
- 38
- 90
-
I want to run the particular function invoking the subprocess command in a continuous loop. But not sure if doing this with `shell=True` is a good idea or not. What could be the other way of achieving this? – user9022502 Jan 30 '18 at 18:18
-
You could start them separately, and make sure the first one is executing in the background. You'll want to wait for them both to be finished before continuing. – jpaugh Jan 30 '18 at 19:06