LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   running SHell script from java (https://www.linuxquestions.org/questions/programming-9/running-shell-script-from-java-274969/)

anirudh 01-07-2005 07:52 AM

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

zeropash 01-07-2005 08:22 AM

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)

anirudh 01-07-2005 08:37 AM

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


All times are GMT -5. The time now is 09:37 AM.