What kind of error? I have no problems calling the single string signature
of exec, the command you show here executed, both as an array and as a single
string ( "/bin/sh -c grep -in main *.java > list &" ) although that didn't
do the same as the three element array... because the two are not the same
command. The single string doesn't work at a shell prompt either (grep doesn't
understand the usage) therefore the "> list" part isn't going to have anything
to do, and the "&" part is irrelevant... of course what you meant was
"/bin/sh -c \"grep -in main *.java > list\" &" or some such wasn't it... :)
either way, the command executed fine on RH5.2, 117_v1a. -=Chris
At 07:11 AM 4/19/99 -0400, Bill Paladino wrote:
>
>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]
>
>
!NEW!-=> <*> cabbey at home dot net http://members.home.net/cabbey/ <*>
"What can Microsoft do? They certainly can't program around us." - Linus
-----BEGIN GEEK CODE BLOCK----- Version:3.12 http://www.geekcode.com
GCS$/IT/PA$ d(-) s++:+ a-- C+++$ UL++++ UA++$ P++ L++ E- W++ N+ o? K? !P
w---(+)$ O- M-- V-- Y+ PGP+ t--- 5++ X+ R tv b+ DI+++ D G e++ h(+) r@ y?
------END GEEK CODE BLOCK------
----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]