0

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

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

1 Answers1

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