Find the answer to your Linux question:
Results 1 to 2 of 2
Like Tree1Likes
  • 1 Post By mizzle
i wanna to write a script to change password for many servers i find a function it can create random password following lines Code: function pwdgen{ while [ "${#pass}" -le ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jun 2014
    Posts
    6

    what does it mean "${#pass}"


    i wanna to write a script to change password for many servers

    i find a function it can create random password following lines
    Code:
    function pwdgen{
    while [ "${#pass}" -le "$passLen" ] 
    do 
    		        passUp="${strUp:$(($RANDOM%${#strUp})):1}" 
    		        passLow="${strLow:$(($RANDOM%${#strLow})):1}" 
    		        passNum="${strNum:$(($RANDOM%${#strNum})):1}" 
    
    pass="$pass$passUp$passLow$passNum" 
    done 
    }
    what is ${#pass}? and following "${strUp:$(($RANDOM%${#strUp})):1}"
    who can explain it thx for any help

  2. #2
    Linux Engineer
    Join Date
    Apr 2012
    Location
    Virginia, USA
    Posts
    913
    Check out this: Manipulating Strings

    As an aside, I'm not sure this is the best way to change the password on a bunch of servers.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •