加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

如何在buildbot中的shell命令行中添加“\u0026\u0026”

发布时间:2020-12-15 21:00:35 所属栏目:安全 来源:网络整理
导读:我需要使用“”一步执行多个命令所以我创建工厂如下: f1 = factory.BuildFactory()f1.addStep(shell.ShellCommand,command=["sh","-c","pwd","","cd","/home/xxx/yyy","pwd"]) 但是在执行过程中发现buildbot会按如下方式处理它,这使得它无法执行 sh -c pwd
我需要使用“&&”一步执行多个命令所以我创建工厂如下:

f1 = factory.BuildFactory()
f1.addStep(shell.ShellCommand,command=["sh","-c","pwd","&&","cd","/home/xxx/yyy","pwd"])

但是在执行过程中发现buildbot会按如下方式处理它,这使得它无法执行

sh -c pwd '&&' cd /home/xxx/yyy '&&' pwd

我的期望是什么

sh -c pwd && cd /home/xxx/yyy && pwd

有人可以帮我解决这个问题吗?谢谢.

解决方法

既然你正在使用/ bin / sh,只需用一个字符串调用它:

f1.addStep(shell.ShellCommand,command="pwd && cd /home/xxx/yyy && pwd")

正如文件所说:

The ShellCommand arguments are:

command

a list of strings (preferred) or single string (discouraged) which specifies the command to be run. A list of strings is preferred
because it can be used directly as an argv array. Using a single
string (with embedded spaces) requires the buildslave to pass the
string to /bin/sh for interpretation,which raises all sorts of
difficult questions about how to escape or interpret shell
metacharacters.

它不推荐,但你仍然需要shell,因为&&只在shell中解释.呼叫sh只是多余的.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读