Get Hidden Input from User.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Get Hidden Input from User.
# 1  
Old 03-29-2010
Get Hidden Input from User.

HI All,

I want to take input from user on linux console...but i dont wnt it to be visible.. just like we type password for ssh or scp

Right now I am using "read" to take input from user but it also makes it visible when user type it.

Code:
read -ep "Dear User Please enter password : " pass

and on console user get this
Code:
Dear User Please enter password : hEllo

I dont wnt this hEllo world to be visible when user type it.


Thanks in advance.

regards
-kashif
# 2  
Old 03-29-2010
Use -s option of read.
# 3  
Old 03-29-2010
Code:
#!/bin/ksh
print -n "Enter password - "
stty -echo
read PASSWORD
stty echo

# 4  
Old 03-29-2010
You can use read -s for hiding user input .
This User Gave Thanks to amitranjansahu For This Post:
# 5  
Old 03-29-2010
can you plz give me complete syntax for read -s coz currently I am getting error for this command.

Code:
read -s "Enter Password" pass

Code:
line 3: read: `Enter Password': not a valid identifier

# 6  
Old 03-29-2010
Code:
echo "enter passwd"
read -s    PASS
echo " U R password is $PASS"


Last edited by amitranjansahu; 03-29-2010 at 04:34 AM.. Reason: code tag
# 7  
Old 03-29-2010
Code:
read -s -p "Enter Password" pass

-s for 'secret'
-p for 'prompt'
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Rsync - how to copy hidden folder or hidden files when using full path

Hello. I use this command : rsync -av --include=".*" --dry-run "$A_FULL_PATH_S" "$A_FULL_PATH_D"The data comes from the output of a find command. And no full source directories are in use, only some files. Source example... (2 Replies)
Discussion started by: jcdole
2 Replies

2. Shell Programming and Scripting

User input and run awk using the input

I am trying to allow a user to enter in text and then store that text in a variable $gene to run in an awk command in which those values are used to run some calculations. I am getting syntax errors however, when I try. Thank you :). The awk runs great if it is a pre-defined file that is used,... (7 Replies)
Discussion started by: cmccabe
7 Replies

3. Shell Programming and Scripting

Script interacts with user , based on user input it operates

i have a script which takes input from user, if user gives either Y/y then it should continue, else it should quit by displaying user cancelled. #!/bin/sh echo " Enter your choice to continue y/Y OR n/N to quit " read A if then echo " user requested to continue " ##some commands... (7 Replies)
Discussion started by: only4satish
7 Replies

4. UNIX for Dummies Questions & Answers

List all directories hidden or not hidden

I want to list all directories hidden or not hidden. ls -ld */ => shows only not hidden directories so i guess the answer would be to add the a option to show all files ls -lad */ => not working :confused: ls -la | grep "^d" => works But I would like to know why I can't use ls -lad... (4 Replies)
Discussion started by: servus
4 Replies

5. Shell Programming and Scripting

How to get the user input recursively until the user provides valid input

Hi, echo "Enter file name of input file list along with absolute path : " read inputFileList if then for string in `cat inputFileList` do echo $string done else echo " file does not exist" fi From the above code, if the user enters a invalid file... (1 Reply)
Discussion started by: i.srini89
1 Replies

6. Shell Programming and Scripting

Finding Hidden files and protecting the folder containing hidden files from deletion

Hi. I have a script which is deleting files with a particular extension and older than 45 days.The code is: find <path> -name "<filename_pattern>" -mtime +45 -exec rm {} \; But the problem is that some important files are also getting deleted.To prevent this I have decide to make a dummy... (4 Replies)
Discussion started by: pochaw
4 Replies

7. UNIX for Dummies Questions & Answers

removing a user with hidden files

Hello, I am trying to remove an employing from our database, I have removed all her files but can't remove the directory because of the hidden files. How do I remove the user? Thanks, (1 Reply)
Discussion started by: nov_user
1 Replies

8. Shell Programming and Scripting

Getting user input

I am trying to create a shell (ksh) which has two "read" commands, one which reads a line from a file and another which is inside a loop that reads user input from a keyboard. However, the "read" command inside the loop uses the input from the file and it does not get the user input from keyboard.... (3 Replies)
Discussion started by: stevefox
3 Replies
Login or Register to Ask a Question