Unix/Linux Go Back    


Shell Programming and Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here.

Running Shell Script from Java

Shell Programming and Scripting


Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 08-14-2006
Asty Asty is offline
Registered User
 
Join Date: Aug 2006
Last Activity: 21 August 2006, 2:37 AM EDT
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Running Shell Script from Java

Hi

How can I call a .sh (shell script) from a java procedure? Is this possible at all?
Please tell me.

Thanks.
Asty
Sponsored Links
    #2  
Old Unix and Linux 08-14-2006
apoorvasharma80 apoorvasharma80 is offline
Registered User
 
Join Date: Aug 2006
Last Activity: 20 May 2008, 9:56 AM EDT
Posts: 69
Thanks: 0
Thanked 1 Time in 1 Post
use the java.lang.Runtime's exec() method.
Sponsored Links
    #3  
Old Unix and Linux 08-14-2006
Dhruva's Unix or Linux Image
Dhruva Dhruva is offline
Registered User
 
Join Date: Mar 2006
Last Activity: 2 November 2012, 12:45 AM EDT
Location: India
Posts: 255
Thanks: 0
Thanked 1 Time in 1 Post
here is the small piece of code....


Code:
try
{
  String execString = "ls -all" 
  Runtime r t            = Runtime.getRuntime();
  Process proc        = rt.exec(execString);
  
  /* handle you process from here..  
  outputstreams, inputStreams and such
 */
 
} 
catch (Exception e)
{
  e.printStackTrace()
}

if you face any problem go there
shell script from java
    #4  
Old Unix and Linux 08-14-2006
Asty Asty is offline
Registered User
 
Join Date: Aug 2006
Last Activity: 21 August 2006, 2:37 AM EDT
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks I got it!
Sponsored Links
Closed Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Running remote system shell script and c binary file from windows machine using java ram.sj Shell Programming and Scripting 1 09-29-2011 06:58 AM
Running shell script from java samshaw Shell Programming and Scripting 2 04-25-2009 11:34 PM
Running a Java Programm with a (korn)shell-script simlmf Shell Programming and Scripting 1 01-07-2009 08:59 AM
Running from Shell Vs running from RC script vickylife Solaris 2 07-31-2008 09:01 AM
exit status running java classpath in unix shell mmcds Programming 2 08-02-2007 10:06 PM



All times are GMT -4. The time now is 07:26 PM.