Win a copy of Zero to AI - A non-technical, hype-free guide to prospering in the AI era this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Error while calling a schell script from java

 
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...
 
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...
 
Sheriff
Posts: 22017
108
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Search for and read the JavaWorld article "When Runtime.exec() won't".
reply
    Bookmark Topic Watch Topic
  • New Topic