• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error while calling a schell script from java

 
satishbsk kumar
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Any one please reply...
 
Lorand Komaromi
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The value of scriptName should end with a space!
 
satishbsk kumar
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20610
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Search for and read the JavaWorld article "When Runtime.exec() won't".
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic