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
posted 9 years ago
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.