| Author |
Error while calling a schell script from java
|
satishbsk kumar
Greenhorn
Joined: Jul 24, 2009
Posts: 15
|
|
Hi All,
I am trying to call an unix schell script from my java program using java.lang.Process class.
Code :
testScript.ksh:
--------------
This script will inturn calls an exe file.
I am able to run the script successfully manually using below command
/usr/bin/ksh testScript.ksh argValue.
But, i am getting exit value 139 while calling from java class. From the logs, i am observed that testScript.ksh getting called,but it's failing to call exe file.
Thanks in advance,
Regards
Satish
|
 |
satishbsk kumar
Greenhorn
Joined: Jul 24, 2009
Posts: 15
|
|
Hi All,
Any one please reply...
|
 |
Lorand Komaromi
Ranch Hand
Joined: Oct 08, 2009
Posts: 276
|
|
|
The value of scriptName should end with a space!
|
OCJP 6 (93%)
|
 |
satishbsk kumar
Greenhorn
Joined: Jul 24, 2009
Posts: 15
|
|
Hi Lorand,
Space is present after the scriptName. And also note that after the construction of exeArgument ,
parameter passed to execute() method is
/usr/bin/ksh testScript.ksh argValue.
This is similar to the command which i am running manually. I mean, both commands are same.
And also note that, when i am running manually script is able to generate the full log. Which is zero byte in case of calling from java.
Regards,
Satish Kumar
|
 |
Lorand Komaromi
Ranch Hand
Joined: Oct 08, 2009
Posts: 276
|
|
satishbsk kumar wrote:
Space is present after the scriptName.
Right, sorry, I didn't notice it on the 4th line...
It could be that when you call ksh like this, some environment variables upon which your application depends will not be set. I had a similar issue with bash...
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
Search for and read the JavaWorld article "When Runtime.exec() won't".
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
 |
|
|
subject: Error while calling a schell script from java
|
|
|