vaibhav sharma
vaibhav sharma

Reputation: 60

is it possible to execute a bash script on remote machine using python pexpect

I connected to remote system using Python Pexpect, Now I want to execute some script(available on remote machine) on remote system is it possible?

Upvotes: 0

Views: 599

Answers (1)

Yonatan Kiron
Yonatan Kiron

Reputation: 2818

Yes, you can do it by adding \n between the commands

Or,

child = pexpect.spawn('ssh MACHINE')

child.sendline('command1')
child.sendline('command2')
child.sendline('command3')

child.close()

I would advice you reading this http://pexpect.readthedocs.io/en/stable/overview.html

Upvotes: 2

Related Questions