Runtime and newgrp

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • C. Allen Sher

    Runtime and newgrp

    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.

  • Anthony Borla

    #2
    Re: Runtime and newgrp


    "C. Allen Sher" <C_Allen_Sher@y ahoo.com> wrote in message
    news:p7Wrb.1767 0$In3.2481@lake read01...[color=blue]
    > 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.
    >[/color]

    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.getRunt ime().exec(comm and);

    or maybe the less fancy:

    String[] command =
    {"/bin/sh", "-c", "/bin/newgrp groupname > resultfile"};

    Runtime.getRunt ime().exec(comm and);

    I hope this helps.

    Anthony Borla



    Comment

    Working...