Problem with Runtime.exec() and compound commands in Solaris



I'm trying to use Java's Runtime.exec() to call some unix commands in
an uninstaller. For reasons I don't have time to explain, making a
call to a shell script which executes the unix commands isn't an
option.

In the uninstall process i'm trying to execute the follow unix
compound command:

rmdir /directory >> /tmp/uninstall.log 2>&1

if I run this command from a terminal it runs as expected. If the
directory isn't empty it prints a message to the uninstall.log file.
However, when I try to pass this into the exec command it never writes
the error message to the log file when the directory is not empty.

I read that if there is a space in an argument of a command that you
need to put the command into an String array instead of a string.
Therefore I tried the following with no luck:

Process p = new Process();
....
String[] cmd = new String[]{"rmdir", "/directory", ">>", "/tmp/
uninstall.log", "2>&1";
p = Runtime.getRuntime().exec(cmd).waitFor();

is that the correct way to split up the command to put it into the
String array?

I have a hand full of other commands I am calling in the same way.
All of them execute the Unix command as expected but if any of them
fun into an error, will not print the error message to the
uninstall.log file.

Any help would be greatly appreciated. Thank you!

-Jared

.



Relevant Pages

  • Re: Can I get spotlight to stop searching cd?
    ... Why isn't this and others described in this newsgroup a GUI? ... tend to have all the vowels and pseudo vowels like y removed - so if you ... If you didn't find an interesting name, but want to see if some command ... To make any of the Unix commands into a GUI, ...
    (comp.sys.mac.system)
  • Re: Breaks in Long Unix Commands
    ... Unix commands. ... how the command appears. ... Its been some years since I had to endure the pain of developing Java apps. ... tcross rapttech dot com dot au ...
    (comp.text.tex)
  • Problem with Runtime.exec() and compound commands in Solaris
    ... I'm trying to use Java's Runtime.execto call some unix commands in ... an uninstaller. ... if I run this command from a terminal it runs as expected. ... need to put the command into an String array instead of a string. ...
    (comp.lang.java.help)
  • Re: Display file version in Terminal?
    ... Sorry if the terminology is sloppy. ... Sometimes the "what" command will tell you. ... Are you a programmer? ... That's what the Unix commands are called. ...
    (comp.sys.mac.system)
  • Re: Remove programs with a script?
    ... "You just have to find said uninstaller and the command line options." ... sets a unique GUID in the regisytry that contains all unique values used, ... I would need to remove old Lotus Notes installations from 40 PC's. ...
    (microsoft.public.scripting.wsh)