在远程主机上运行脚本并查看输出

时间:2016-03-01 16:01:43

标签: python linux python-2.7 paramiko

在服务器上我只是这样运行:

root@web:~# /var/www/PHP/controller.py | cut -f 4 -d ','
    nan
    nan
    nan

来自外部机器的Paramiko脚本:

 #!/usr/bin/python
    for i in range (0,10000):
            ssh = paramiko.SSHClient()
            ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
            ssh.connect('192.168.122.100',username='user',password='lol')
            stdin,stdout,stedrr = ssh.exec_command("/var/www/PHP/controller.py | cut -f 4 -d ','")
            print stdout.read()

但输出为空。有谁知道什么可能是错的?

1 个答案:

答案 0 :(得分:0)

与评论中的建议相同,每当你卡住并且stdout没有提供任何信息时,请看看stderr

可能是机器用户没有足够的权限来访问它,或者任何其他问题......

尝试使用paramiko运行controller.py脚本,看看stdout,stderr中发生了什么。当你管理它然后继续削减

+1用于密码选择

相关问题