Visit Jeremy's Blog.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


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

Rep: Reputation: 15
Exclamation running SHell script from java

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
Old 01-07-2005, 08:22 AM   #2
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, 08:37 AM   #3
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
its working now


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 05:36 AM
running shell scripts using Java niravk8 Programming 2 02-09-2005 10:42 AM
How to use Java in a Shell Script arnneisp Programming 1 07-13-2004 03:18 AM
shell script to compile java czy11421 Programming 4 04-30-2004 10:42 AM
c/c++ running a shell script? thermalpants Programming 3 05-12-2002 12:41 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:52 PM.

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