LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-07-2005, 06:52 AM   #1
anirudh
Member
 
Registered: Aug 2004
Location: bangalore india
Posts: 50

Rep: Reputation: 15
Exclamation running SHell script from java


hi
how can i run a shell script from a java program
i tried usind exec method from the runtime class but i could not run it
the shell script is very simple it onle does a ls -l
but i wanted to know how to do this
can anybody help me with an example
thnx
 
Old 01-07-2005, 07:22 AM   #2
zeropash
Member
 
Registered: Apr 2003
Location: Bangalore,India
Distribution: FC2, RHES, RH9, FC3, FC1, Slackware 3.0
Posts: 208

Rep: Reputation: 30
I dont know java much but are you trying to exec the shell script ?
you should be execing the shell (/bin/sh or whatever and giving the script as an argument)
 
Old 01-07-2005, 07:37 AM   #3
anirudh
Member
 
Registered: Aug 2004
Location: bangalore india
Posts: 50

Original Poster
Rep: Reputation: 15
oh cool
got it man
i was trying to run the script directly i need to run /bin/sh first
Runtime.getRuntime().exec (new String[]{"/bin/sh", "-c", "echo $SHELL"}

and then the sh file
cool
thnx
its working now
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Running shell scripts from Java cmpich Programming 1 04-19-2005 04:36 AM
running shell scripts using Java niravk8 Programming 2 02-09-2005 09:42 AM
How to use Java in a Shell Script arnneisp Programming 1 07-13-2004 02:18 AM
shell script to compile java czy11421 Programming 4 04-30-2004 09:42 AM
c/c++ running a shell script? thermalpants Programming 3 05-12-2002 11:41 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:17 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration