0

So I've been using subprocess and pexpect to try to interact with a separate program running in the terminal. I need to feed it a command, with arguments, and be able to receive it's response and potentially send it more commands.

With subprocess, I have only been able to launch a terminal, but not feed it commands. Or I can pass ONE line of command to an emulated terminal within python. The issue it that it's one-and-done and I can't really interact with it.

pexpect seems to only be able to initiate one command, and then respond to the terminal in an automated fashion, I couldn't find relevant and up to date documentation that went over what I needed.

Are there better modules to use for this? Or am I using them the wrong way? -Thanks, -Sean

1 Answer 1

1

pexpect is your best candidate, as far as I'm aware.

It's documentation matches version on pypi - 3.2 as for now.

If you would like to run bunch of commands one after another you can try to divide commands with ";" or "&", depends on your usage.

Btw. please take a look at example section.

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.