Golang exec.command with input redirection

前端 未结 2 1478
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-21 06:27

I\'m trying to run a fairly simple bash command from my Go code. My program writes out an IPTables config file and I need to issue a command to make IPTables refresh from t

2条回答
  •  春和景丽
    2020-12-21 07:09

    cmd := exec.Command("/usr/sbin/iptables-restore", "--binary", iptablesFilePath)
    _, err := cmd.CombinedOutput()
    if err != nil {
        return err
    }
    return nil
    

    this work fine on my Raspberry Pi3

提交回复
热议问题