1

How can i from a python script emulate user data like:

Say i run os.system('grunt init:gruntfile'), and i want the python script automatically to 'enter' some data, so instead of the user inputs the data that the shell command asks for, the python script enters some data hard-coded in the script?

Hope my question makes sense and that someone can help. Thank you in advance, adam

1 Answer 1

3

pexpect will probably fit your bill if plain old subprocess doesn't.

From the pexpect site:

For example::

child = pexpect.spawn('scp foo [email protected]:.')
child.expect ('Password:')
child.sendline (mypassword)
Sign up to request clarification or add additional context in comments.

1 Comment

Can i get the output of the shellcommand in the python console?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.