我如何在一个无用的触发器中运行多个命令

时间:2019-03-14 16:34:29

标签: bash command vagrant

我想在触发器中运行mtuliple命令,但似乎只允许我运行一个。下面的代码有效:

  config.trigger.after :up do |trigger|
     trigger.info = "Do something"
     trigger.run = {inline: "echo hi"}
  end

这些替代品都不能用于最后一行:

     trigger.run = {inline: "echo hi; echo hi again"}
     trigger.run = {inline: "echo hi && echo hi again"}

似乎无所事事来解析它们,它使用shellsplit并希望将所有内容作为一个具有多个参数的命令来运行,因此;&&会出现在回显中。

例如:

    trigger.run = {inline: "echo test; test 2 &&"}

输出:

    default: echo test; echo test 2 &&
    default: test; echo test 2 &&

2 个答案:

答案 0 :(得分:0)

那这样的事情呢?

df = pd.DataFrame({'one':['bab'],'two':['abb'],'three':['bb']})
Source_Dictionary = {'one':{'dadd':1,'bab':1.5},
                    'two':{'ab':2},
                    'three':{'cc':1,'bb':3}}
required_columns = ['one','two','three']
def Feature_Map(x):
    df[x] = df[x].map(Source_Dictionary[x]).fillna(0)

for i in required_columns:
    Feature_Map(i)
print(df)
   one  two  three
0  1.5  0.0      3

答案 1 :(得分:0)

这件事花了我很多时间,但我终于弄明白了。触发器没有运行bash脚本,它们正在执行二进制文件。因此,您必须执行以下操作:

trigger.run = {inline: "bash -c 'echo test; test 2 &&'"}

来源:https://www.vagrantup.com/docs/triggers/configuration.html#run