2020年9月6日星期日

perform-commands-over-ssh-with-python

perform-commands-over-ssh-with-python

>>> import  subprocess
>>> subprocess.Popen("ssh -p {port} {user}@{host} {cmd}".format(port='2223', user='admin', host='192.168.1.1', cmd='nvram get wan0_realip_ip'), shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
(b'192.36.222.246\n', b'')
 
 
或者使用
subprocess.check_output(  )

没有评论: