Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

password in a script

Status
Not open for further replies.

we2aresame

Technical User
Feb 10, 2003
128
CA
I try to write a script which will su to another user to run some commands, how to give the password in the script, thanks.
 
Use sudo, it's easier to script for.

There is a way of doing it using "expect" but I'm not familiar with it.
 
or, if root is going to execute the script, the syntax is, for example:

su oracle -c "$ORACLE_HOME/bin/dbstart"

(All required paths and environment settings are stated before this line.)
 
That will work bi, but I wonder about the password in a script as well. Maybe not the best tool for this job, but is it possible without a C program?
 
I think the expect route Chapter11 discussed would be a fairly easy way (I've heard -- I've not actually written an expect script). The problem with having a password in any file is the security hole it creates. (And also, I think you would need to have the password for if you use sudo in a script, too.)
 
we2aresame,bi is obviously correct.
To have a file with the not-encrypted password of another user is as dangerous as suppressing password validation for that user.
sudo is the best thing for executing command like another user .... if you don't wish to write a your own application
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top