Sponsored Content
Top Forums Shell Programming and Scripting While loop running after reaching limit Post 302586022 by Vaibhav.T on Friday 30th of December 2011 02:12:40 AM
Old 12-30-2011
MySQL While loop running after reaching limit

Hi frnds

i am newbie in linux and trying to write a simple script for adding users.the problem is i am running a while loop under function and loop is running for 3 time more than limit.Here is my Script and output pls help me out :

Code:
 # CREATE N NO. OF USERS WITH PASSWORD IN SYSTEM



# ./users to run the script

# CREATE A FUNCTION CALLED ADD()

ADD ()

{

   while [ $i  -le $no ]

      do
          echo -e " Please enter the user name :\t\c"
          read USER

#  Search in /etc/passwd file for user existence

          output=`cat /etc/passwd | grep $USER | cut -d: -f1`


            if [ "$output" = "$USER" ]

            then

    echo " Opps ! $USER is already exist Please Enter again"


## Call ADD Function in case of User already exist

                  ADD
            fi

           useradd $USER

          echo -e " Please enter the Password of the user :\t\c"

          read PASSWD

          echo $PASSWD | passwd --stdin $USER

echo "$USER creates successfully"

          i=`expr $i + 1`


done

}


clear

echo -e " Please Enter How many users want to create :\t\c"

read no

i=1


# Call ADD Function

ADD

OUTPUT of Script :

Code:
 Please Enter How many users want to create :    2
 Please enter the user name :    viv

 Opps ! viv is already exist Please Enter again

 Please enter the user name :    vishnu
 Opps ! vishnu is already exist Please Enter again

 Please enter the user name :    ram
useradd: user 'ram' already exists
 Please enter the Password of the user :    kev

Changing password for user ram.
passwd: all authentication tokens updated successfully.
ram creates successfully

 Please enter the user name :    john
 Please enter the Password of the user :    john
Changing password for user john.
passwd: all authentication tokens updated successfully.
john creates successfully

useradd: user 'john' already exists
 Please enter the Password of the user :    john
Changing password for user john.
passwd: all authentication tokens updated successfully.
john creates successfully

useradd: user 'john' already exists
 Please enter the Password of the user :    jhon
Changing password for user john.
passwd: all authentication tokens updated successfully.
john creates successfully
[root@Riyansh Scripts]#

pls help me out

thanks


vaibhav

Last edited by methyl; 12-30-2011 at 06:31 AM.. Reason: please use code tags when posting code or data
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to limit the number of running instances of a script?

I would like to allow only one instance of a script to run at any moment. I've tried the following solution to count the instances but the result is always the number of running instances plus one and I can't find the problem ps -ef | grep $0 | sed '/^$/ d' | sed '/grep/ d' | wc -l Please... (2 Replies)
Discussion started by: oti
2 Replies

2. AIX

Real memory usage is reaching 99.99%

Hi i am new to aix , we are using aix 5.3 version and model is 510 and 520 model servers. in our servers contains 8 gb ram. but servers average ram usage is reaching 99.9% , can any body help on this , is any impact if memory usage reach 99.9%. Regards Balaji Poola (2 Replies)
Discussion started by: Balajipoola007
2 Replies

3. IP Networking

trouble reaching local router interface

I have a processor (Solaris 5.8) with a router locally attached. We're having trouble pinging the router interface from the processor with a normal ping command. The response from the router is "administratively prohibited", which normally indicates the access list on the router is bouncing... (1 Reply)
Discussion started by: jalburger
1 Replies

4. Shell Programming and Scripting

Limit of ls command in for loop

I am using the code below to list all the Errors files from the directory in the for loop. When the number of files are less then 6000 then it's works fine but if it more than that then for loop fails. for file in `ls $ERR_DIR/PPL_Prov_Engine_Error_*` do memrecno=`cut -f2 -d'|' $file` ||... (6 Replies)
Discussion started by: mr_harish80
6 Replies

5. UNIX for Advanced & Expert Users

Limit on Number of Cron Jobs Running on one Account

Hello, I have some 150 Cron Jobs running under my UNIX account. I want to add some more jobs. Is there a limit to the number of cron jobs that can be run on an account? Thank you. Pramodini (8 Replies)
Discussion started by: Pramodini Rode
8 Replies

6. Shell Programming and Scripting

Running script automatically when threshold limit met in one of the field in oracle database

Hi Guys, Need you help in one point! I am working on one shell script which takes following steps : 1. Taking one query result from oracle database 2. Exporting that result to Xls file 3. Mailing that file to my own mail ID Now, I want to give a threshold limit to one of the column... (0 Replies)
Discussion started by: Agupte
0 Replies

7. Linux

Lan card not reaching Gateway

Hi, I have this problem on RHEL box. I am using two NIC's of same model and make (Intel 82557) in the adjacent PCI slots . I am using each one for different subnet and have assigned them ipaddresses and gateways of respective subnets . While one is O.K. connecting to its ... (5 Replies)
Discussion started by: dextergenious
5 Replies

8. What is on Your Mind?

Congratulations Corona688 for reaching to landmark of 4000+ THANKS

Hello All, Let's join our hands together to appreciate Corona688 for completing and reaching to the landmark of 4000+ THANKS. I do want to appreciate Corona688 on behalf of everyone here in forum for Corona688's continuous effort of posting very useful, full of experience and knowledge posts in... (7 Replies)
Discussion started by: RavinderSingh13
7 Replies

9. Shell Programming and Scripting

While loop with limit counter

#!/usr/bin/ksh c=0 while ]; do echo /tmp/unex NOT found, iter : $c; ((c = $c + 1)); sleep 2; done so, the above counter doesn't work, already tried both -lt & -gt, and changed || to && so what am I missing? Thanks in advance (5 Replies)
Discussion started by: unexistance
5 Replies

10. Shell Programming and Scripting

Limit on number of pipes after long-running command?

I'm trying to create a minimal, crude keylogger for X using only a shell script. I was quickly stumped: Why do these two commands entered in a terminal emulator produce output when I type... $ xinput test 6 | grep press $ xinput test 6 | awk '{print $3}' ...but this command produces no... (13 Replies)
Discussion started by: DevuanFan
13 Replies
pwconv(1M)                                                System Administration Commands                                                pwconv(1M)

NAME
pwconv - installs and updates /etc/shadow with information from /etc/passwd SYNOPSIS
pwconv DESCRIPTION
The pwconv command creates and updates /etc/shadow with information from /etc/passwd. pwconv relies on a special value of 'x' in the password field of /etc/passwd. This value of 'x' indicates that the password for the user is already in /etc/shadow and should not be modified. If the /etc/shadow file does not exist, this command will create /etc/shadow with information from /etc/passwd. The command populates /etc/shadow with the user's login name, password, and password aging information. If password aging information does not exist in /etc/passwd for a given user, none will be added to /etc/shadow. However, the last changed information will always be updated. If the /etc/shadow file does exist, the following tasks will be performed: Entries that are in the /etc/passwd file and not in the /etc/shadow file will be added to the /etc/shadow file. Entries that are in the /etc/shadow file and not in the /etc/passwd file will be removed from /etc/shadow. Password attributes (for example, password and aging information) that exist in an /etc/passwd entry will be moved to the corre- sponding entry in /etc/shadow. The pwconv command can only be used by the super-user. FILES
/etc/opasswd /etc/oshadow /etc/passwd /etc/shadow ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
passwd(1), passmgmt(1M), usermod(1M), passwd(4), attributes(5) DIAGNOSTICS
pwconv exits with one of the following values: 0 SUCCESS. 1 Permission denied. 2 Invalid command syntax. 3 Unexpected failure. Conversion not done. 4 Unexpected failure. Password file(s) missing. 5 Password file(s) busy. Try again later. 6 Bad entry in /etc/shadow file. SunOS 5.10 9 Mar 1993 pwconv(1M)
All times are GMT -4. The time now is 12:41 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy