【问题标题】:Groovy shell script doesn't recognize export commandGroovy shell 脚本无法识别导出命令
【发布时间】:2019-04-15 17:58:48
【问题描述】:

我正在运行一个 groovy 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)

export 命令在 bash 中运行时工作正常,那么我应该在 groovy 中做什么才能使其工作?

【问题讨论】:

    标签: bash macos groovy groovyshell


    【解决方案1】:

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

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

    【讨论】: