繁体   English   中英

使用paramiko运行bundle命令

[英]Running bundle command using paramiko

我正在尝试使用python的paramiko模块执行rake任务。

我有以下代码:

ssh_client = paramiko.SSHClient()
ssh_client.load_system_host_keys()
ssh_client.connect(myserver, username="root")
ssh_stdin, ssh_stdout, ssh_stderr = ssh_client.exec_command("cd /mnt/app-production/current ; export PATH=/usr/local/rubies/1.9.2-p320/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games ; bundle exec rake images:load_swatch")
print ssh_stdout.read()
print ssh_stderr.read()

但是我得到以下输出:

rake aborted!
LoadError: no such file to load -- ruby-debug
/mnt/app-production/releases/20141113171842/config/application.rb:7:in `<top (required)>'
/mnt/app-production/releases/20141113171842/Rakefile:5:in `require'
/mnt/app-production/releases/20141113171842/Rakefile:5:in `<top (required)>'
(See full trace by running task with --trace)

这是什么错误? 我如何成功执行命令?

谢谢

我认为问题是您尝试使用exec_command运行多个命令。 检验一下: 如何在Paramiko中的单个会话中执行多个命令? (蟒蛇)

我设法通过使用以下使其工作:

ssh_stdin, ssh_stdout, ssh_stderr = ssh_client.exec_command(" export PATH=/usr/local/rubies/1.9.2-p320/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games ; 
export RUBBER_ENV=production ; 
export RAILS_ENV=production; 
cd /mnt/app-production/current ; bundle exec rake images:load_swatch")

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM