Python paramiko在尝试运行bash shell时挂起

时间:2015-02-11 08:36:18

标签: python bash python-2.7 python-3.x paramiko

我需要在远程服务器上的bash shell中运行回归脚本。我能够使用paramiko成功连接并执行不同的命令。但是当我尝试执行' / bin / bash'我的Python脚本永远挂起:

stdin,stdout,stderr = ssh.exec_command("pwd;/bin/bash;echo $SHELL")

没有/ bin / bash echo $ SHELL运行良好并返回以下内容:

[u'/home/akar\n', u'/tools/cfr/bin/tcsh\n']

有没有解决方法?

1 个答案:

答案 0 :(得分:1)

我的第一个疑问是你正在执行的bash的目的是什么。字面意思是:

pwd; #print '/home/akar\n' as it results
/bin/bash; #/bin/bash will take over of console(stdin/stdout/stderr) from here
echo $SHELL #when you input exit to exit the bash from line 2, line 3 will print