Groovy Shell脚本无法识别导出命令

时间:2019-04-15 17:58:49

标签: bash macos groovy groovyshell

我正在运行一个普通的shell脚本,在这里我想在运行aws命令之前设置代理:

export http_proxy=http://proxy.url.com:8099
aws s3 ls

但是我遇到了这个错误:

Caught: java.io.IOException: Cannot run program "export": error=2, No such file or directory
java.io.IOException: Cannot run program "export": error=2, No such file or directory
    at com.capitalone.cep.lensOps.run(lensOps.groovy:13)

当我在bash中运行export命令时,该命令可以正常工作,那么该如何使其正常工作呢?

1 个答案:

答案 0 :(得分:1)

export是一个shell功能,而不是一个外部程序。要在其环境中运行具有特定值的程序,可以改用env

env http_proxy=http://proxy.url.com:8099 aws s3 ls