I have a python script that establishes ssh connected using os.system()
function :
def livestream():
os.system('ssh -X ubuntu@192.168.0.2')
os.system('cd Desktop') #doesn't get executed on remote machine
I know that os.system()
executes commands on the same machine.
Further, I need to execute a program present on the remote machine.
My question is how do I execute bash commands in python once ssh connection is established?
答案 0 :(得分:2)
def livestream():
os.system('ssh -X ubuntu@192.168.0.2 "cd Desktop"')
答案 1 :(得分:1)
You can use the call
method from the subprocess
module.