The RunTime class seems to be VERY cranky about the String command it sees
to exec a program. Only likes String arrays and generates a Run Time error
if you pass it the command as a SINGLE string formatted the same way as the
String-array. Following works OK but if you change the runCmd to a String...
import java.io.*;
public class RunFile {
public static void main ( String args[] )
throws Exception {
try {
Runtime rt = Runtime.getRuntime ();
// Build a cmd-string :
String [] runCmd = { "/bin/sh", "-c",
"grep -in main *.java > list &" };
System.out.println ("RunCmd: " + runCmd[0] +
runCmd [1] + runCmd [2]);
Process procs = rt.exec (runCmd);
BufferedReader br = new BufferedReader
(new InputStreamReader (procs.getInputStream()));
String line;
while (( line = br.readLine () ) != null )
System.out.println (line);
} catch (IOException ioe) {
System.out.println ("Runtime/Process error");
} // end try
} // end main
} // end class
Any ideas?
--------------------------------------------
Bill Paladino
Senior Programmer
BASCOM Global Internet Services
275-R Marcus Blvd
Hauppauge, NY 11788
516 434 6600 / www.bascom.com
----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]