While I can see the delma that you are trying to tackle, I can only say
that command chaining is not possible(after many frustrated attempts).
I had to use it to call an independent compiler/vm from my Java IDE.
However, I can suggest that you try to abstract all the operations that
you need to do into a script file and then exec() that instead as it is a
lot cleaner and less stressful.

Hope this helps you.

Ricky Szeto
        E-mail                  [EMAIL PROTECTED]
                                [EMAIL PROTECTED]
        Homepage                http://www.scs.ryerson.ca/~rszeto


On Wed, 4 Aug 1999, Susan Moffat wrote:

> Hi
>
> I'm trying to perform unix commands from my Java program and have tried
> using the Runtime class as follows:
>
>     Process proc = Runtime.getRuntime().exec("/bin/sh -c \"ls;pwd\"");
>
> to try to perform more than one command in the same runtime instance.
> Apparently calling exec again will result in a new process being ran and as
> I'm trying to perform the commands using the same instance (I'll actually be
> trying to use the "su" command and perform several commands whilst as the
> superuser).
>
> I've also tried writing to the returned Process class's output stream by
> using a BufferedWriter taking an OutputStreamWriter from the
> Process.getOutputStream() method - to no avail. As when I perform the
> flush() on the writer, an IOException occurs with a write error thrown in
> the FileOutputStream.write() method, which flush() inherits from.
>
> Has anyone managed to perform operating system commands from within their
> Java code?
>
> Thanks, Susan
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to