go执行shell脚本报错:exec: executable file not found in $PATH

缺乏、安全感 2023-01-16 03:25 325阅读 0赞

代码示例:

  1. command := exec.Command("ls ~ | grep .zip")

报错:

  1. exec: "pidof tor | xargs kill -HUP": executable file not found in $PATH

解决:

  1. // 添加额外参数 bash -c
  2. command := exec.Command("bash","-c","ls ~ | grep .zip")
  3. // 或
  4. command := exec.Command("sh","-c","ls ~ | grep .zip")

发表评论

表情:
评论列表 (有 0 条评论,325人围观)

还没有评论,来说两句吧...

相关阅读