aspose file tools*
The moose likes Linux / UNIX and the fly likes Problem with su - user_name inside script Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Problem with su - user_name inside script" Watch "Problem with su - user_name inside script" New topic
Author

Problem with su - user_name inside script

Chandrakanth
Ranch Hand

Joined: Aug 16, 2005
Posts: 60
Hi All,

could you pls help me in getting this resolved.

I have a script..inside the script i am doing su - ashok, i have the user ashok's password in the file.

when i do su - ashok, the script is asking the user for the password.
i want to read the password to read from the file and give as input to su command.

can anybody tell me how to do the same.

script:
swithuser.sh
su - ashok
Martin Simons
Ranch Hand

Joined: Mar 02, 2006
Posts: 196
You would be much better off by installing and using something like sudo which will allow you to do things like this (in a controlled and regulated manner) without using passwords. I am willing to bet that your script has read permissions for all others and I am certain that ashok loves it that everyone can read his password (if they know where to find the script).

You really should not be passwords and/or passphrases in scripts. Like I said use "sudo", or something similar. Google for and download it, if it is not already installed. If you are using some form of Linux, I can would bet that it already is installed.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem with su - user_name inside script
 
Similar Threads
how to assign password for a user in shell script
String Encryption
split function problem in AWK
How to create password protected file
setuid