LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   invalid numeric argument (https://www.linuxquestions.org/questions/linux-general-1/invalid-numeric-argument-1542/)

Copenhagen Cowboy 03-28-2001 11:10 AM

This is really beginning to irritate me.

I have taken the adduser script from Slackware 7.1 and am trying to modify it to work on Red Hat 7. The script will run up to actually making the account. Then I get error:

useradd: invalid numeric argument '-g'

-g is the initial group, which would be "users". What am I doing wrong??

crabboy 03-28-2001 08:31 PM

I'm not sure what you are doing wrong, but I can suggest a way to debug.

Run the adduser script using bash debug features.

# bash -x adduser

This will display each line of the script as it executes. After you have entered all the required info. Watch for the call to the useradd program. After the script has errored out, type in the useradd command exactly as the script tried to execute it.

Now you can modify the useradd command line until the user gets added. Take the successful parameter sequence and/or format and modify the script write the useradd command that way.

If you really feel that useradd will not take the group command as it should, then download the useradd source and debug it.

Good Luck

Copenhagen Cowboy 03-29-2001 09:55 AM

I found where the problem lies. When it goes through the command line, it doesn't read the variable for user id. It's leaving that blank. So, it shows the next thing on the line to be "-g" for user id.

The portion of the script for user id reads:

echo
echo -n "User id for $LOGIN [default to next available]: "
read ID
GUID="-u $ID
if [ -z "$ID" ]; then
GUID=""
fi

This is exactly how it is written in Slackware.

Any ideas??

Copenhagen Cowboy 03-29-2001 12:03 PM

Ok, I've got the script working as long as I actually enter a user id number. It will actually go through and finish the script and make the account, but I would like to have it assign the user number automatically. Is there a way to do that??

Copenhagen Cowboy 03-29-2001 02:01 PM

FYI
 
I figured out the problem last mentioned. All I needed to do is add a line in there under if:

ID=""

Once I added that in, it automatically started assigned UID's.

Thanks for the debug command, crabboy. Once I got that, I was able to figure it out.


All times are GMT -5. The time now is 12:28 AM.