Hi all,
The code I try to execute an external program.
For my servlet program,
To launch a Unix script String[] cmd = {"/bin/sh", "-c", "ls >
out.dat"};
Runtime.getRuntime().exec(cmd);
==
try {
String[] command = {"/bin/sh", "-c", "/bin/ls > out.dat"};
Process p = Runtime.getRuntime().exec(command);
p.waitFor();
System.out.println("return code: " + p.exitValue());
} catch (IOException e) {
System.err.println("IO error: " + e);
} catch (InterruptedException e1) {
System.err.println("Exception: " + e1.getMessage());
}
==
Process p = Runtime.getRuntime().exec("/usr/local/bin/test"); is
okay, too. (without parameter)
== (test is a simple c execute program)
HOWEVER, I try to change the command line to
String[] command = {"/usr/local/bin/test > /tmp/tmp.dat"}
It does not work!!
Because ">" is a shell command! It must be interpreted by /bin/sh.
So! How do I execute a external program with shell command?
--> String[] comand = {"/bin/sh", "-c", "/usr/local/bin/test >
/tmp/tmp.dat"};
It still does not work...
Anybody kindly give me some hints?
Thanks!
___________________________________________________________________________
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