• 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
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

Java and Shell scripts

 
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So because the platform I'm developing a Java application for is Solaris, I need to be able to run a mount CD or USB script which is provided to me. The script will return a status code...so first question is, where do I start looking at to execute and get the status code of the script?
Second question is, if the status code is 0 (as in failure), the script will echo out some sort of meaningful error message. I would like to capture that and be able to display it in a error dialog...how would I go about capturing that.
Also (probably a little bit outside of this forum, but I'll give it a shot)...does the script run in a separate shell? Like if I have System.outs in my main program, and then run the script, will I have an issue capturing the echo outputs from the script?
Thanks!
 
Eric Chang
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's the actual script (sorry, it's a bit long...but I'm not knowledgable enough with shell scripting to know what parts are important).



What puzzles me is that there does not seem to be any status or exit if the mount of the CD is successful or not which leads me to believe that there needs to be some work done on the script.
Nevertheless, if someone can decipher this stuff and help me out, it would be greatly appreciated.
 
Master Rancher
Posts: 4250
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look at the Process class. It will run a command and allow you to get its output with various methods.

The script looks like it returns a 0 on success and a 1 on failure.
 
Eric Chang
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Excellent, thanks for pointing me in the right direction!
 
Marshal
Posts: 72407
315
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Norm Radder:
Look at the Process class.

More discussion about running Processes here, and in the associated links in that thread.
 
If tomatoes are a fruit, then ketchup must be a jam. Taste this tiny ad:
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic