"C. Allen Sher" <C_**********@yahoo.com> wrote in message
news:p7Wrb.17670$In3.2481@lakeread01...
Has anyone ran the Unix "newgrp" command from a java Runtime object? I
can't seem to get it to work the way it should.
Issuing *NIX and Linux command-line [i.e. shell] commands can be tricky,
particularly if multiple arguments and file redirection is involved.
Try:
String shell = "/bin/sh",
shellOpts = "/c",
cmd = "/bin/newchrp",
cmdArgs = "groupname > resultfile";
String[] command = { shell, shellOpts, cmd, cmdArgs };
Runtime.getRuntime().exec(command);
or maybe the less fancy:
String[] command =
{"/bin/sh", "-c", "/bin/newgrp groupname > resultfile"};
Runtime.getRuntime().exec(command);
I hope this helps.
Anthony Borla