fabric 远程部署 vps 的时候,总是说:run() received nonzero return code 127 while executing。有人遇到了吗?

2014-08-06 21:42:20 +08:00
 no13bus
代码如下:
env.hosts = ['100.100.100.100']
env.user = 'root'
env.password = "root"
def test():
with cd('/tmp'):
run('ls')
print 'donedonedone'
4534 次点击
所在节点    问与答
9 条回复
kfll
2014-08-06 21:56:55 +08:00
127是命令没找到吧…试着看看环境变量
no13bus
2014-08-06 21:59:35 +08:00
@kfll 你的意思是说vps里面的环境变量不对?
no13bus
2014-08-06 22:55:49 +08:00
no13bus
2014-08-06 22:57:37 +08:00
siteshen
2014-08-06 23:23:40 +08:00
fabric默认使用bash执行命令,服务器上安装没有bash?
两种解决方案:1. 服务器上安装bash(为什么这个都没有??!!);2. 参考fabric.api.run函数的文档,指定env.shell:
run(command, shell=True, **kwargs)


Run a shell command on a remote host.

If ``shell`` is True (the default), `run` will execute the given command
string via a shell interpreter, the value of which may be controlled by
setting ``env.shell`` (defaulting to something similar to ``/bin/bash -l -c
"<command>"``.) Any double-quote (``"``) or dollar-sign (``$``) characters
in ``command`` will be automatically escaped when ``shell`` is True.
no13bus
2014-08-07 00:07:57 +08:00
@siteshen 确实如此。run(command, shell=True, **kwargs)已经解决。多谢了
no13bus
2014-08-07 01:13:09 +08:00
run(command, shell=False, **kwargs)已经解决
dafang
2014-08-07 07:46:39 +08:00
fabric 代码写的还是太多,推荐用ansible
no13bus
2014-08-07 08:21:30 +08:00
@dafang 这还多呀。我觉得已经很少了。我看看你推荐的。多谢

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/126472

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX