Mulesoft 无法 运行 shell 脚本

Mulesoft cannot run a shell script

我正在尝试 运行 在 Mulesoft 的 Anypoint Studio 的流程中编写 shell 脚本。

虽然我可以得到一些基本的 shell 到 运行,但我无法得到我的脚本到 运行。这是我的脚本的样子:

#!/bin/ksh
export JWHome=${pwd}
export LOG4J_JAR=$JWHome/lib/log4j-1.2.7.jar
export CLASSPATH=$JWHome/lib/java.jar:$LOG4J_JAR:$JWHome

我将上面的脚本设置为有效负载并通过 运行ning 从 Groovy 脚本执行它:

payload.execute().text

当我 运行 这个脚本时,我得到以下错误:

java.io.IOException: Cannot run program "#!/bin/ksh": error=2, No such file or directory
I get the same error when I remove "#!/bin/ksh" - For example when I run Export to set a variable.

我怎样才能把它送到 运行?

我假设你所做的 - 你没有提供足够的细节 - 是使用 Groovy 脚本来执行负载中使用 execute() method 的字符串的内容。这是失败的,因为 shell 脚本不是单个命令。只有 shell 可以解释它,但不能作为命令行。

您可以尝试将shell脚本内容写入文件(例如:myscript.sh,或使用临时名称),然后按名称执行shell脚本("myscript.sh".execute()).您可能需要添加正确的文件路径,否则 execute() 方法可能找不到它。