Alex D.
Alex D.

Reputation: 73

Python run a Linux command and then leave the terminal to user

I am writing a remote login script that should just run a command (log me in to a device via telnet or ssh) and then just leave the terminal to me.

I tried subrocess.Popen module and for windows host I managed to achieve what I needed, the script opens putty or SecureCRT via a cmd command logging me in and then stops leaving the window to me.

In Linux it's a little different though, I want the script to run a command in the terminal and then I should be able to continue working on the terminal myself. I tried subrocess with not much luck.

I can achieve this with pexpect.interact() but it seems that it will be more efficient if after logging me in the python script stopped as it is not needed anymore, if it is possible of course.

Upvotes: 0

Views: 386

Answers (1)

Ron
Ron

Reputation: 6601

Try pwntools http://docs.pwntools.com/en/latest/intro.html#making-connections

It has a nice interactive mode.

Check the examples on the page I linked.

Upvotes: 1

Related Questions