Now,here is an executable program that I run in a shell. But It needs parameter.How can I use python to pass parameter to the program in a shell. I know a tool in unix named 'expect' which can interact with existing software. I want to know if python can do the same thing! My english is not good~sorry~
1 Answer
Use the subprocess module. Basic example:
>>> import subprocess as sub
>>> sub.call(["ls", "-l"])
Basically you can pass the command and its parameters as a list of strings.
EDIT: Reading again your question I wonder if pexpect is indeed what you want.