How can I open in Python a unix shell, type a command and some other inputs and close the unix shell?
Example commands and inputs:
telnet 127.0.0.1:6000
user
pass
save-all
restart
Greets
miny
How can I open in Python a unix shell, type a command and some other inputs and close the unix shell?
Example commands and inputs:
telnet 127.0.0.1:6000
user
pass
save-all
restart
Greets
miny
You can have a look at the pexpect
module and more precisely the interact function.
See documentation here.
Basically, you juste spawn your sheel, program or whatever you want, and interact with it like you would normally do.
import pexepect
p = pexpect.spawn('/bin/bash')
p.interact()
Then you escape with an escape character as explained in the doc.