Reputation: 3075
I am on system with ip x . I want to ssh into system with ip y from X , do some work on y shell using x and come out exit into x again .. using python
I have following code snippet in python that i intend to run on x
if __name__ == "__main__":
print "inside main of python file"
command="ssh [email protected]"
output=subprocess.Popen(command, shell =False )
When i run this i was hoping that new shell will open on the current shell and then i can go ahead wrkg with 172.1.1.2 .. However I found that my current shell got corrupted after ssh to 172.1.1.2 was done .
I think i am doing something wrong .
Upvotes: 0
Views: 94
Reputation: 1106
Its better to use 'fabric' if you want to run shell commands through ssh, assuming that you will be creating a python+shell script of a repetitive task. In any case, you could just run the fabric tasks through IPython, gain access and do whatever shell based activity from within IPython itself.
If however you want a Bash/*SH shell access, then its preferable to use expect to perform the login and create a shell for you on the remote server.
Upvotes: 1