Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with su - user_name inside script

 
Chandrakanth
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic