V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
no13bus
V2EX  ›  问与答

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

  •  
  •   no13bus · 2014-08-06 21:42:20 +08:00 · 4516 次点击
    这是一个创建于 3522 天前的主题,其中的信息可能已经有所发展或是发生改变。
    代码如下:
    env.hosts = ['100.100.100.100']
    env.user = 'root'
    env.password = "root"
    def test():
    with cd('/tmp'):
    run('ls')
    print 'donedonedone'
    9 条回复    2014-08-07 08:21:30 +08:00
    kfll
        1
    kfll  
       2014-08-06 21:56:55 +08:00 via Android
    127是命令没找到吧…试着看看环境变量
    no13bus
        2
    no13bus  
    OP
       2014-08-06 21:59:35 +08:00
    @kfll 你的意思是说vps里面的环境变量不对?
    no13bus
        3
    no13bus  
    OP
       2014-08-06 22:55:49 +08:00
    no13bus
        4
    no13bus  
    OP
       2014-08-06 22:57:37 +08:00
    siteshen
        5
    siteshen  
       2014-08-06 23:23:40 +08:00   ❤️ 1
    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
        6
    no13bus  
    OP
       2014-08-07 00:07:57 +08:00
    @siteshen 确实如此。run(command, shell=True, **kwargs)已经解决。多谢了
    no13bus
        7
    no13bus  
    OP
       2014-08-07 01:13:09 +08:00
    run(command, shell=False, **kwargs)已经解决
    dafang
        8
    dafang  
       2014-08-07 07:46:39 +08:00
    fabric 代码写的还是太多,推荐用ansible
    no13bus
        9
    no13bus  
    OP
       2014-08-07 08:21:30 +08:00 via Android
    @dafang 这还多呀。我觉得已经很少了。我看看你推荐的。多谢
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   954 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 20:36 · PVG 04:36 · LAX 13:36 · JFK 16:36
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.