papillon has asked for the wisdom of the Perl Monks concerning the following question:

Hello, I am trying to add linux user. the system() call to useradd return an error that I don't get using the same line directly at linux prompt.
system ("useradd", '-K UID_MIN=2000', "-g $gid", "-m", "-p $hash", "$u +ser");
I get the following error message:
configuration error - unknown item ' UID_MIN' (notify administrator)
If I print the line result instead and then directly put it at system prompt, the command execute succesfully.
$ useradd -K UID_MIN=2000 -g 2000 -m -p $... username
Any idea what cause the configuration error? Thanks

Replies are listed 'Best First'.
Re: using UID-MIN
by MidLifeXis (Monsignor) on Jan 24, 2014 at 21:23 UTC

    Each parameter ("-g $gid", for example), should be separate parameters ('-g', $gid). You are creating a single parameter of the form -g $gid instead of two parameters (the flag and the value). This should be done for every flag+value that you have combined into a single parameter.

    --MidLifeXis

      Using separate parameter for each flag and value solve my problem. Thanks, Papillon
Re: using UID-MIN
by NetWallah (Canon) on Jan 24, 2014 at 20:49 UTC
    This is just a guess, based on the error message:
    It looks like the leading space implies improper parsing - try this:
    system ("useradd", '-K','UID_MIN=2000', "-g $gid", "-m", "-p $hash", " +$user");

            If your eyes hurt after you drink coffee, you have to take the spoon out of the cup.
                  -Norm Crosby