1

Following the advice given in; Calling an external command in Python

I have been experimenting using the call() function to call an external command, however the command I need to call is being called correctly but it does not like the parameters being passed to it. This is because the Call function is passing the parameters with ' 's around them.

E.g

test = call(['/opt/program/something/lookup', 'search "bob"'])

The search part must be passed to the command lookup without any characters surrounding it, I have tried a few different permutations of the call function with varying levels of quotes, spaces, lack of commas etc. The second statement - bob, must be within quotes.

Is there a clean way to do this?

Example of return value of test atm;

Error: 'search "bob"' is not a valid command.
Community
  • 1
  • 1
Draineh
  • 599
  • 3
  • 11
  • 28

1 Answers1

6

This should work - if not then please update the question with specific error text:

test = call(['/opt/program/something/lookup', 'search', '"bob"'])
S.Lott
  • 384,516
  • 81
  • 508
  • 779
ed.
  • 1,373
  • 8
  • 10