且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Java中使用Process Builder在Linux上执行海关命令

更新时间:2023-12-04 08:06:40

默认情况下,进程不在shell上下文中执行;因此您的shell脚本无法以您尝试的方式执行.

Process does not by default execute in the context of a shell; therefore your shell scripts cannot be executed the way you tried.

ProcessBuilder pb =
    new ProcessBuilder( "/bin/bash",
                        "-c", 
                        ". setProto.sh && . setTls.sh && /anloss -i ${TOOL_INPUT}/census_10000_col5.csv  -d ${TOOL_DEF}/attr_all_def.txt -q k=14,dage=2 -g ${TOOL_RES}/census_100_col8_gen.csv" );

我不确定/anloss-命令位于root的主目录/中是不寻常的. (此外,您在Shell脚本前面有/.-它们应该实现什么?)

I am not sure about /anloss - it's unusual for a command to be in root's home /. (Also, the /. you had there in front of the shell scripts - what should they achieve?)

稍后

请确保将/anloss替换为相对于$HOME/PVproto/Base的绝对路径名,例如,如果该目录中的,请使用,如果在$HOME/PVproto/Base/SomeSub中,请使用SomeSub/anloss,等等.

Make sure to replace /anloss with an absolute pathname or a relative pathname relative to $HOME/PVproto/Base, e.g., if it is in this directory, use ./anloss, if it is in $HOME/PVproto/Base/SomeSub, use SomeSub/anloss, etc.

此外,如果是setProto.sh和. setTls.sh不在$HOME/PVproto/Base中,请使用适当的绝对或相对路径名.如果是,请使用./setProto.sh./setTls.sh避免依赖于环境变量PATH的设置.

Also, if setProto.sh and . setTls.sh are not in $HOME/PVproto/Base, use an appropriate absolute or relative pathname. If they are, use ./setProto.sh and ./setTls.sh to avoid dependency on the setting of environment variable PATH.