0

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!

3 Answers 3

1

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)

Sign up to request clarification or add additional context in comments.

1 Comment

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)
0

remove the shell=True. It's unnecessary.

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

Comments

0

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.

6 Comments

Thank you Daniel and Andrew. Ok, I removed the shell=True and the commas. When I did that and selected return, I got Traceback errors. subprocess.call(['c:\Program Files (x86)\Internet Evidence Finder\IEF.exe' '--image' 'J:\IEFTest\IEFTest001.E01' '--search' 'quick' '--output' 'J:\IEFTest\CommandLineTest\WindowsTest2'] is the command I'm trying to run. I want the files to generate to the WindowsTest2 Folder. I also tried removing the quotes around the J:\IEFTest\IEFTest001.EO1 and received an syntax error on the J drive.
My answer was actually kind of unclear. But either way, you can't take out shell=True and remove the commas. I'm going to edit my answer, but consider reviewing list syntax. Once shell=True is removed you need to pass the arguments as a list. I would use this: subprocess.call("c:\Program Files (x86)\Internet Evidence Finder\IEF.exe --image J:\IEFTest\IEFTest001.E01 --search quick --output J:\IEFTest\CommandLineTest\WindowsTest2", shell=True)
Ok, thank you Andrew. I tried it but still got the return of 1. I'll review the list syntax again. Thank you for your help. I'm attempting to learn this in a very short period of time, and I know only practice will make it better. Much appreciated!
Did you try the list of arguments without shell=True like Daniel suggested? I've always had bad luck with that in linux but it might work better in windows. In that case you would use subprocess.call(['c:\Program Files (x86)\Internet Evidence Finder\IEF.exe', '--image', 'J:\IEFTest\IEFTest001.E01', '--search', 'quick', '--output', 'J:\IEFTest\CommandLineTest\WindowsTest2'])
I did remove it. I also tried it the way you typed it. I still got the error of -1. This may just be a command that I can't use the subprocess module for. I'll see if there is another way to do it. Thank you again!
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.