mmullinix
mmullinix

Reputation: 11

Using Subprocess.call I want to run an executable from another program

I have a command line executable that I want to call with subprocess.call. The call itself to the application works.

subprocess.call(['filepathIEF.exe'], shell=True). This part works fine.

I want to automate this command:

IEF.exe --image [image path] -- search [type] --output [output path]

When I broke it down by pieces, IEF.exe works fine, then I got a -1 error when I added the

'--image', 'Filepathofimage'], shell=True)

I then tried adding each piece of this CLI and received an error of 1, then, I tried placing the whole line in one '' and I received the error of 1. I only started using Python about 2 months ago and I still have much to learn. I also tried the Popen and it returned an error of

When this command is run in the CLI, it generates a set of files inside the file I name as the output. I could really use some assistance on this. I'm sure I'm just missing something simple, but I'm not seeing it. Thank you for your help in advance!

Upvotes: 0

Views: 1619

Answers (3)

mmullinix
mmullinix

Reputation: 11

Instead of subprocess.call the Popen command works.

command = ['c:\Program Files (x86)\Internet Evidence Finder\IEF.exe', '--image', 'C:\Users\examiner\Documents\IEFTest\UbuntuTest.001', '--search', 'quick', '--output', 'c:\Users\examiner\Documents\IEFTest\CommandLineTest\UbuntuTest4']

subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)

Upvotes: 1

Andrew F
Andrew F

Reputation: 13

Take out the commas, brackets, and inner quotes. shell=True means you are passing the command and arguments as a string and not as a list.

Upvotes: 0

Daniel
Daniel

Reputation: 42758

remove the shell=True. It's unnecessary.

subprocess.call(['filepath/IEF.exe', '--image', image_filename])

Upvotes: 0

Related Questions