I feel like this a pretty dumb ?, but I am trying to call a script in Linux. Code looks like this: class callscript { public static void main(String args[]) throws Exception { String item = "sh -c ./mescript"; Process proc = Runtime.getRuntime().exec(item); int rc = proc.waitFor(); } } mescript is just supposed to do an 'ls -al' It compiles and runs but no output. I have tried to replace the String with 'sh -c ls' No luck. Any ideas. Thanks, Bill Norton
Cindy Glass
"The Hood"
Sheriff
Joined: Sep 29, 2000
Posts: 8521
posted
0
Well I don't know Unix much, but in windows you would start a .bat file using: Runtime.getRuntime().exec("cmd /c start run.bat");
"JavaRanch, where the deer and the Certified play" - David O'Meara
Thomas Whalen
Ranch Hand
Joined: Aug 26, 2001
Posts: 123
posted
0
i know this is a little off-track, but could you point me to a link that explicitly describes how to make a batch file in Win98/NT ? i don't like having to do dig up my java files from the command line so that i can run them. thanx
if you don't know, then ask. if you do know, then share. love is knowledge.
Cindy Glass
"The Hood"
Sheriff
Joined: Sep 29, 2000
Posts: 8521
posted
0
Open notepad and type your commands, and save it with a .bat extension. Or if you are at the DOS prompt just type >edit whatever.bat type your commands and save. Make sure that they land in the directory that you will invoke them from (or in the path of course).
I am also interested in how this would work. I searched around and found a couple of clues. If your command has spaces in it you want to do some thing like this:
And also saw a couple of examples that looked like this.
I still have not figured out how to put it all together.
[This message has been edited by christopher foran (edited November 20, 2001).]
Please ignore post, I have no idea what I am talking about.
This is most likely really ugly code (hopefully someone will jump in and clean it up) but it works. By works I mean that I get the results of an "ls -l" command at the command line I run the java program from.
[This message has been edited by christopher foran (edited November 21, 2001).]