Hi,
I’m calling the following shell script locally from a java service in webMethods.
#!/bin/ksh
abc.sh $1
echo $?
This script will call another script abc.sh which returns a flag of value 0/1/2/3 and I am echoing the return value.
When I run this from unix prompt I get a return value 2(which looks ok) but when i run the java service I get the output as 1. Can anyone tell me what is going wrong ?
My java code looks like this:
#########################################
IDataCursor idcPipeline = pipeline.getCursor();
String line = null;
Vector ssOut = new Vector();
String fullCommand ;
String successFlag = “false”;
String scriptOutput = null ;
try {
Process child = Runtime.getRuntime().exec(fullCommand);
int exitValue = child.waitFor();
if(exitValue==0){
InputStream iStm = child.getInputStream();
InputStreamReader isReader = new InputStreamReader(iStm);
BufferedReader br = new BufferedReader(isReader);
while ( (line = br.readLine()) != null)
ssOut.add(line);
int size = ssOut.size();
scriptOutput = ssOut.elementAt(size-2).toString();
successFlag=“true”;
}else{
exitvalue = exitValue;
successFlag=“false”;
}
}
catch (Throwable e) {
successFlag=“false”;
}
finally{
idcPipeline.insertAfter(“successFlag”, successFlag); idcPipeline.insertAfter(“outFlag”, outs);
idcPipeline.insertAfter(“scriptOutput”, ssOut);
//Destroy the cursor
idcPipeline.destroy();
}
#########################################
Will appreciate if anyone can suggest something to solve my problem.
Thanks