I think the syntax of useradd and the pipe for passwd is not working
properly. I would love to move forward from this as I'm stuck here
Thank you guys.
On Tue, May 5, 2020 at 8:28 PM Muhammed Suhail <[email protected]>
wrote:

> Hello again, Ragini,
>
> So I used [[ $UID != 0 ]] to check for root.
>
> @Nikhilesh I modified the script and find below the latest iteration:
> #!/bin/bash
> #!/bin/sh
> if [[ $UID != 0 ]]
> then
>  exit 1
> fi
>
> if [[ $?=0 ]]
> then
>  read -p 'Enter the new username' $USER_NAME
>  read -p 'Enter Real name' $COMMENT
>  read -p 'Enter password' $PASSWORD
> else
>  exit 1
> fi
> #create account
> if [[ "${?}" == 0 ]]
> then
>  useradd -c "${COMMENT}"-m $USER_NAME
>  echo $PASSWORD | passwd --stdin ${USER_NAME}
>  echo Working...
> else
>  echo not working
>  exit 1
> fi
>
> if [[ $? == 0 ]]
> then
>  echo "Account Created" "Username: ${user_name}, Host: ${HOSTNAME}"
>
>
> Issues:
> -So I had a previous iteration which gives an error "Unexpected end of
> file"
> - The script fails at the useradd command.
>
>
> Thanks for the help @Nikhilesh @ Ragini
>
> On Sun, May 3, 2020 at 12:18 PM RAGINI <[email protected]> wrote:
>
>>
>>
>> >  -------Original Message-------
>> >  From: Muhammed Suhail <[email protected]>
>> >  To: [email protected] <[email protected]>
>> >  Subject: [foss] Need help
>> >  Sent: May 02 '20 21:15
>> >
>> >  Hey I'm trying to run the following script. But the program is not
>> >  running after the initial input stage:
>> >
>> >  #!/bin/bash
>> >
>> >  if [[ $UID != 0 ]]
>> >  then
>> >  exit 1
>> >  fi
>> >
>> If you run this part of the code, what do you get ?
>>
>> And can you explain this step over here.
>>
>> thanks
>> Ragini
>>
>

Reply via email to