0

I have viewed some methods of calling an external program using python, the main method is to use subprocess, however I also want to execute the commands of that external program.

For example:

In python:

  1. call that program;

  2. execute command "operation1" (this is not a Python command but a command used in the external program);

  3. print intermediate results;

Thank you very much!

user186927
  • 23
  • 3

1 Answers1

0
from subprocess import call
call(['someAppName', 'someArg'])

Can you just pass a command line argument to the application you're trying to run?

Aesthete
  • 18,622
  • 6
  • 36
  • 45
  • Does this have benefits over the `os` modules's `os.system()`? – kyle k Sep 20 '13 at 06:06
  • @Aesthete I did something like this: subprocess.call(['./file_folder/./program', 'read ./A/file.v', 'print']) If I run the read and the print commands directly in that program, I can print out what the program has read. But now I was only redirected to the program, and read and print are not executed. I use terminal to run the subprocess.call method instead of writing it to a python file then executing the python file. – user186927 Sep 20 '13 at 06:39