Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Search Forums:



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 10-26-2005
whatisthis's Avatar
Registered User
 

Join Date: Aug 2004
Posts: 175
Thanks: 0
Thanked 0 Times in 0 Posts
Hide Password

Hi,
I am trying to write a shell script to call ftp program to send files to windows shared drive.
I don't want my user to directly deal with ftp program, so I use shell as an interface to allow them to give userID and password.
Is there anyway that I can hide the password when user input within shell program just like when we log into Unix?


Any help would be appreiciated!
Sponsored Links
    #2  
Old 10-26-2005
Perderabo's Avatar
Unix Daemon (Adminstrator Emeritus)
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,679
Thanks: 26
Thanked 238 Times in 148 Posts
#! /usr/bin/ksh

print -n "Enter password - "
stty -echo
read PASSWORD
stty echo
print

Then just use $PASSWORD where you need it.
Sponsored Links
    #3  
Old 10-27-2005
Registered User
 

Join Date: Feb 2004
Posts: 92
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by Perderabo
#! /usr/bin/ksh

print -n "Enter password - "
stty -echo
read PASSWORD
stty echo
print

Then just use $PASSWORD where you need it.
Another option depending on the shell is:
echo "Enter password"
read -s PASSWORD
    #4  
Old 10-27-2005
whatisthis's Avatar
Registered User
 

Join Date: Aug 2004
Posts: 175
Thanks: 0
Thanked 0 Times in 0 Posts
stty -echo

Thanks for all the help!!
Sponsored Links
    #5  
Old 07-21-2008
Registered User
 

Join Date: Jul 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
You can type
echo Please enter the password
stty -echo
read $passwd
stty echo

also you can put *** instead of password on console
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How Do I Hide the Password in a Script samd Shell Programming and Scripting 6 11-22-2006 04:38 AM
Want to hide password arpitk Shell Programming and Scripting 1 09-29-2006 08:42 AM
Hide oracle password on unix process list acheepi Shell Programming and Scripting 3 10-06-2005 09:25 PM
How to hide password on Linux? nir_s Shell Programming and Scripting 2 02-09-2005 11:24 AM
hide password typing ivancheung Programming 2 09-30-2004 01:05 PM



All times are GMT -4. The time now is 05:01 AM.