>>>>> "Jason" == Jason Janelle <[EMAIL PROTECTED]> writes:

    Jason>    I have been writing java on WindowsNT boxes for a while
    Jason>    and am just trying out java on Linux.  I was trying to
    Jason>    issue a command to the system via this line of code:

    Jason>    Runtime.getRuntime().exec("ls > dir.txt");

    Jason>    It compiles and such but I get no dir.txt.  I tryed a
    Jason>    waitFor() statement but no help.  In windows you have to
    Jason>    do "cmd /c dir > dir.txt" in the exec() and I was
    Jason>    wondering if you have to specify a shell for linux to
    Jason>    run in as well. 

Yes, redirection is shell feature and Runtime.exec() doesn't provide a 
shell. Try
Runtime.getRuntime().exec(new String[] {"/bin/sh", "-c", "ls >dir.txt"});


        Juergen

-- 
Juergen Kreileder, Blackdown Java-Linux Team
http://www.blackdown.org/java-linux.html
JVM'01: http://www.usenix.org/events/jvm01/


----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to