Reputation: 275
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
Upvotes: 1
Views: 2219
Reputation: 168834
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)
Upvotes: 3