Re: Runtime and newgrp
From: Anthony Borla (ajborla_at_bigpond.com)
Date: 11/11/03
- Next message: Russ Reynolds: "Java Binary I/O And Networking Question"
- Previous message: Anthony Borla: "Re: Check for admin privilege"
- In reply to: C. Allen Sher: "Runtime and newgrp"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 11 Nov 2003 04:50:51 GMT
"C. Allen Sher" <C_Allen_Sher@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
- Next message: Russ Reynolds: "Java Binary I/O And Networking Question"
- Previous message: Anthony Borla: "Re: Check for admin privilege"
- In reply to: C. Allen Sher: "Runtime and newgrp"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|