1

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
  • raise an example to make it clear Commented Dec 27, 2011 at 15:56

1 Answer 1

4

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.

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.