This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Building Blockchain Apps and have Michael Yuan on-line!
See this thread for details.
Win a copy of Building Blockchain Apps this week in the Cloud/Virtualization 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
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

Java and Shell scripts

 
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Rancher
Posts: 3656
34
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Excellent, thanks for pointing me in the right direction!
 
Marshal
Posts: 68109
258
  • Mark post as helpful
  • send pies
  • 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.
 
See ya later boys, I think I'm in love. Oh wait, she's just a tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!