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

Reply via email to