The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Running shell script from java samshaw Shell Programming and Scripting 2 04-25-2009 11:34 PM
How to call Java by using shell script aaabbb123123 Shell Programming and Scripting 2 08-21-2008 02:02 AM
Unix Shell script vs Java navojit dutta Shell Programming and Scripting 13 08-11-2007 09:18 PM
Running Shell Script from Java Asty Shell Programming and Scripting 3 08-14-2006 09:08 AM
run java using shell script inpavan UNIX for Dummies Questions & Answers 1 03-14-2002 10:38 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-26-2009
crackthehit007 crackthehit007 is offline
Registered User
  
 

Join Date: Feb 2009
Location: Pune/Banagalore
Posts: 71
run shell script in java?

hi,
how to run shell script in java?

i have script a.sh which takes 1 argument as input and returns exit code integer.
how to handle it in java.
should i have to invoke process to execute it and then wait til it completes ?

please explain with code

thanks
  #2 (permalink)  
Old 09-26-2009
varontron varontron is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 110
haven't done this in a while, but I think it's:
Code:
try {
  java.lang.Process process = java.lang.Runtime.getRuntime().exec("command args");
  int retCode = process.exitValue();
}
catch (Exception e) {  }
If the 'exitValue()' method doesn't work, you may need to use 'getOutputStream()' to get the return value which is piped to stdout.

hth,
dv
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:47 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0