| | |
Passing a variable with a password to the SU command
Please support our Shell Scripting advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Nov 2004
Posts: 8
Reputation:
Solved Threads: 0
I am trying to install 2 rpm files that need root privileges. However, I don't want to prompt the user twice. Currently I am doing the following in my script:
echo "*************************************************************"
echo "In order to install acme package, you need to log in as root"
echo "*************************************************************"
su -c "ACME_QUIET=y rpm -ivh /home/acmeUser/acme_install/components/acme/acme*"
echo "**************************************************************************"
echo "In order to install acmebase package, you need to log in as root."
echo "**************************************************************************"
su -c "rpm -ivh /home/acmeUser/acme_install/components/acme/acmebase*"
The above works just fine. However, they have to login twice.
I would like to do something like this:
echo "*************************************************************"
echo "In order to install acme package, you need to log in as root"
echo "*************************************************************"
read PASSWORD
I would then like to give the $PASSWORD variable to the SU command somehow. I just can't seem to figure it out. Another option would be to use SUDO (so people tell me), but I thought you had to configure it before hand. This is a script that is run on many many machines and I can't configure SUDO for this purpose. Does anyone have an idea on how to get around this?
Thanks!
echo "*************************************************************"
echo "In order to install acme package, you need to log in as root"
echo "*************************************************************"
su -c "ACME_QUIET=y rpm -ivh /home/acmeUser/acme_install/components/acme/acme*"
echo "**************************************************************************"
echo "In order to install acmebase package, you need to log in as root."
echo "**************************************************************************"
su -c "rpm -ivh /home/acmeUser/acme_install/components/acme/acmebase*"
The above works just fine. However, they have to login twice.
I would like to do something like this:
echo "*************************************************************"
echo "In order to install acme package, you need to log in as root"
echo "*************************************************************"
read PASSWORD
I would then like to give the $PASSWORD variable to the SU command somehow. I just can't seem to figure it out. Another option would be to use SUDO (so people tell me), but I thought you had to configure it before hand. This is a script that is run on many many machines and I can't configure SUDO for this purpose. Does anyone have an idea on how to get around this?
Thanks!
•
•
•
•
Originally Posted by stharmon
I am trying to install 2 rpm files that need root privileges. However, I don't want to prompt the user twice. Currently I am doing the following in my script:
echo "*************************************************************"
echo "In order to install acme package, you need to log in as root"
echo "*************************************************************"
su -c "ACME_QUIET=y rpm -ivh /home/acmeUser/acme_install/components/acme/acme*"
echo "**************************************************************************"
echo "In order to install acmebase package, you need to log in as root."
echo "**************************************************************************"
su -c "rpm -ivh /home/acmeUser/acme_install/components/acme/acmebase*"
The above works just fine. However, they have to login twice.
I would like to do something like this:
echo "*************************************************************"
echo "In order to install acme package, you need to log in as root"
echo "*************************************************************"
read PASSWORD
I would then like to give the $PASSWORD variable to the SU command somehow. I just can't seem to figure it out. Another option would be to use SUDO (so people tell me), but I thought you had to configure it before hand. This is a script that is run on many many machines and I can't configure SUDO for this purpose. Does anyone have an idea on how to get around this?
Thanks!
--HV
•
•
Join Date: Nov 2004
Posts: 8
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by Comatose
I understand what ; does on a command prompt and what not. What I DON'T understand, is how you were able to pass the password to SU with multiple commands (using ; )? So how'd you do it?
. That way the users were only prompted once during the install... If you ever find out how to pass the password to SU, I would like to know as well... ![]() |
Similar Threads
- Problem with equal mark in input variable (Shell Scripting)
- Problem with equal mark in input variable (Windows NT / 2000 / XP)
- How to pass a shell variable to a perl command (Shell Scripting)
- Passing variable sql php (PHP)
Other Threads in the Shell Scripting Forum
- Previous Thread: "shell scripting tutorials?"
- Next Thread: Why my shell script doesn't delete a file ??
| Thread Tools | Search this Thread |






