Jump to content
  • 0

Question

i have a short script to add new  users with groups and passwords

the last question asks

"do you want to add another user (y/n)?'

                  # ## then if the answer is  y  I want to run the script  of 5 questions again. as a while condition

while  [  "$CLEANYORN=" = "y" ]

do

  ./script3

 done

 

So I have done this WHILE  loop, which does not error and when true (y)  it goes back to command line and does not execute the script again to add another user.

 

Link to post
Share on other sites

5 answers to this question

Recommended Posts

  • 0

Hi cher,

Where have you defined the CLEANYORN variable? You can't set CLEANYORN variable from script3.

Define CLEANYORN variable before the while loop and set it to "y". Then, inside the while loop, after running ./script3, read the CLEANYORN variable from the user.

image.png.f74e669036cbf632ef5aca450b9ae97c.png

 

I hope it helps.

Shovon

Link to post
Share on other sites
  • 0

I have   CLEANYOURN='echo $YORN | cut  -c  -1 | tr [:upper:] [:lower:]'    this  $YORN is the read from  the yes or no answer from the question do you want to run the script again

Link to post
Share on other sites
  • 0

Shovon,

 I have   CLEANYORN='echo $YORN | cut  -c  -1 | tr [:upper:] [:lower:]'    this  $YORN is the read from  the yes or no answer from the question do you want to run the script again  and then takes the yes or no ( or Y or N) down to just a lowercase one letter  from the users answer   as    y  or n  .....

 

CLEANYORN='echo $YORN | cut  -c  -1 | tr [:upper:] [:lower:]'    that is then why the = = in the while   command  

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...