如何在python脚本上运行此SSH?
ssh gateway@192.168.0.189 'DISPLAY=:0 notify-send "Title" "Description"'
我的python脚本将要求Title
的raw_input()和Description
的另一个。然后python将运行SSH,插入用户键入的Title
和Description
。
答案 0 :(得分:2)
import subprocess
subprocess.check_call(
'''ssh gateway@192.168.0.189 'DISPLAY=:0 notify-send "{0}" "{1}"' '''.format(title, description),
shell=True)
答案 1 :(得分:1)
如果您想要更多控制,还应该查看paramiko库:https://github.com/paramiko/paramiko这是一个用于python的SSH2库。