1834814 Members
3074 Online
110070 Solutions
New Discussion

Password hidden

 
SOLVED
Go to solution
Achilles_2
Regular Advisor

Password hidden

Hi all,

I am starting to write a script about to create a user. It contains account password and path name. My questions are:

1) If I ask the user to set the password, the output will display on the screen? How to avoid to display? My srcipt is:

printf "Set the password: "
read temp

2) Also when the user enter the path namee likes /home/temp/, but I want to cut character "/" for the output, so that the output likes home/temp? Do anyone have an idea to do it?

Thanks
7 REPLIES 7
RAC_1
Honored Contributor

Re: Password hidden

trap 'stty echo; exit' 0 1 2 3 15
printf "Set the password: "
stty -echo
read temp
stty echo

read home
home1=${home#/} --> will give home/temp/
There is no substitute to HARDWORK
VEL_1
Valued Contributor
Solution

Re: Password hidden

Hi,

refer the following script:

#!/usr/sbin/sh

echo "Enter the password"
stty -echo
read str
stty echo
echo "Got the password: $str"


Achilles_2
Regular Advisor

Re: Password hidden

Hi RAC

thanks your help first, now if the user type /home/temp/, and I want the output likes --> home/temp

how do i do?

Thx again
RAC_1
Honored Contributor

Re: Password hidden

echo ${home#/}

Will give you what you want.
There is no substitute to HARDWORK
Arunvijai_4
Honored Contributor

Re: Password hidden

# echo ${PATH#/}
usr/sbin:/usr/bin:/usr/ccs/bin:/usr/contrib/bin:

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Howard Marshall
Regular Advisor

Re: Password hidden

If you are just looking to strip the leading / off the string if its there this is one way among many to do it.

I don't know what your scripting skill level is do don't be afraid to ask what something means or the though process behind it.

#assign the string to a variable
DIR=$1

if [ `echo $DIR | cut -c 1` - \/ ]
then
DIR=`echo $DIR | cut -c 2-`
fi

echo input was $1 and it converted to $DIR
Arturo Galbiati
Esteemed Contributor

Re: Password hidden

read Home_Directory
print ${Home_Directory#/}

HTH
Art