Drush commands not executing using Paramiko如何使用的paramiko更改目录?
我发布了上述关于使用Paramiko收到的持续性错误消息的问题。我不认为这与我的下一个问题有关,但可能是。
我可以通过使用SSH的paramiko成功地连接到我的服务器。我可以执行像ls或pwd这样的命令。我似乎无法做的是改变目录。我可以发送命令“CD ..”例如,但当我跟进“PWD”这说明我没有改变目录。它只是列出了我登录的初始目录我。
>>> stdin, stdout, stderr = myssh.exec_command("pwd")
>>> stdout.readlines()
['/big/dom/home/myid\n']
>>> stdin, stdout, stderr = myssh.exec_command("cd ../")
>>> stdout.readlines()
[]
>>> stdin, stdout, stderr = myssh.exec_command("pwd")
>>> stdout.readlines()
['/big/dom/home/myid\n']
>>>
我误解这是怎么回事?我应该无法更改目录吗?或者,如果我可以,我应该这样做比使用exec_command一些其他的方式?
-
我不能回答我自己的另一7小时问题,所以这里的答案:
这家伙有它想通了:http://www.vertigrated.com/blog/2010/02/python-remote-ssh-with-paramiko/
你只需要发送多个)
然后stdout.readlines(将;
myssh.exec_command( 'PWD CD ..'):用一种exec_command命令,如返回您更改的目录。
[如何在Paramiko的单个会话中执行多个命令? (Python)](https://stackoverflow.com/questions/6203653/how-do-you-execute-multiple-commands-in-a-single-session-in-paramiko-python) – tripleee