This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Java in General and the fly likes Error while calling a schell script from java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Error while calling a schell script from java" Watch "Error while calling a schell script from java" New topic
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: 19672
    
  18

Search for and read the JavaWorld article "When Runtime.exec() won't".


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error while calling a schell script from java