![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| OS X (Apple) OS X is a line of Unix-based graphical operating systems developed, marketed, and sold by Apple. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| sudo, use in script without prompt for password | gauravgrover50 | Shell Programming and Scripting | 4 | 04-25-2009 08:26 AM |
| sudo command with password | chebarbudo | Shell Programming and Scripting | 1 | 12-29-2008 08:13 AM |
| Works from bash prompt, but not from script! | siegfried | Shell Programming and Scripting | 7 | 02-10-2008 02:56 PM |
| verify sudo password | mdpalow | Shell Programming and Scripting | 0 | 12-20-2007 10:53 PM |
| sudo in OS X shell script without password prompt?? | Brad_GNET | UNIX for Dummies Questions & Answers | 1 | 07-29-2005 06:36 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Bash script prompt for sudo password?
I'm making a script that will be a double clickable .command file and I need it to prompt for the users admin password.
So far I have: Code:
if [[ "$(/usr/bin/whoami)" != "root" ]]; then
sudo -p "Please enter your admin password: " date 2>/dev/null 1>&2
if [ ! $? = 0 ]; then
echo "You entered an invalid password or you are not an admin/sudoer user. Script aborted."
exit 1
fi
fi
Thanks. |
|
||||
|
Try this code:
Code:
sudo -p "Please enter you admin password: " whoami 1>/dev/null && {sudo whoami;sudo whoami;whoami;sudo -k}
|
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|