- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- password for script
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2003 05:06 PM
10-23-2003 05:06 PM
password for script
I have written a script but what I want is whenever someone run the script it will prompt for the password and if its wrong exit the script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2003 05:12 PM
10-23-2003 05:12 PM
Re: password for script
I know "C" and i know that it can solve you'r problem.
Ok here is how you can go
1. read the used id.
2. get the salt characters from /etc/passwd or if trusted system read from tcb files (salt characters are first 2 characters of password)
3. read the password from keyboard and using the salt character you got from previous step, encrypt the password.
4. compare the password either from /etc/passwd or tcb files if trusted system.
If compare results ok then let user run the script or else exit. You can this way even keep log of users who ran the script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2003 05:29 PM
10-23-2003 05:29 PM
Re: password for script
su $LOGNAME -c /bin/true
if [ $? -ne 0 ]
then
exit
fi
LOGNAME should contain your login name, so you do a su to yourself.
This works in most cases. Only root doesn't need to enter his own password.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2003 07:19 PM
10-23-2003 07:19 PM
Re: password for script
You could write a small C program which would call getpass() and do your validation, returning a success/fail code which your calling script can then check.
Unless maybe perl can do this - I'm no expert here but someone else might be able to help...
-- Graham
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2003 07:51 PM
10-23-2003 07:51 PM
Re: password for script
I guess that you would like to validate his/her unix password when this script is run by a unix account. So the most appropriate method seems the method submitted by Elmar P. Kolkman above.
Addition to the information gathered above, I would like to say comments about the reply submitted by Graham Cameron:
a-) If you want avoid showing Password you may read password interactively as
below.
USERNAME="UserName" ## Could be a parameter to your script too.
PASSWORD=""
while [ ! "$PASSWORD" ]
do
echo "\t\t\tEnter ${SERVER} PASSWORD for ${USERNAME}: \c"
stty -echo
read PASSWORD
stty echo
echo ""
done
b-) As far as I know, function getpass() is limited up to 8 characters, so you'd better consider this limitation while writing codes on your platform.
Regards
ALPER ONEY
SYBASE DBA
I.S.E TAKASBANK INC
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-23-2003 07:58 PM
10-23-2003 07:58 PM
Re: password for script
You have taught me something there.
You deserve points for that.
-- Graham