my dog learned polymorphism
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 Interview Guide this week in the Jobs Discussion 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

Problem with su - user_name inside script

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.

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:
subject: Problem with su - user_name inside script
It's not a secret anymore!