我有这个脚本。
log_file_name=dataProcessor
export pwd=`pwd`
echo "in data processing"
log_file_path=LOGS/data-processor/
logfile=$log_file_path$log_file_name.log
log_file_home_path=LOGS
export LOG_FILE_HOME_PATH=$log_file_home_path
export DATA_EXTRACTION_CONFIG_FILE_LOCATION=$pwd/config.properties
export LIBJARS=/home/data-extraction/2.12.2.1/data-extraction/lib/*.jar
export HADOOP_CLASSPATH=$HADOOP_CLASSPATH:/home/abc/lib/*.jar
echo `$HADOOP_CLASSPATH`
hadoop jar data-processor-*.jar com.impl.JobSubmission -libjars ${LIBJARS} &> $log_file_home_path/process.log
echo "in data processing done"
当我从putty执行它时,它可以正常工作,但是当我们使用java ProcessBuilder执行它时它会失败。它失败了"未找到Hadoop命令"错误。 下面是Java代码,我用它来执行脚本。
ProcessBuilder builder = new ProcessBuilder(command.trim());
//builder.redirectErrorStream(true);
Process process = builder.start();
exitStatus = process.waitFor();
BufferedReader reader =
new BufferedReader(new InputStreamReader(process.getInputStream()));
String line = "";
while ((line = reader.readLine()) != null) {
output.append(line + "\n");
System.out.print(line);
}
答案 0 :(得分:0)
问题是另一个脚本。 脚本一(1)启动Java应用程序,内部调用第二个脚本(s2),该脚本正在下降。脚本一(S1),设置了无效的PATH,而不是PATH,使用了路径,这就产生了整个问题。