get password through shell script
Hi all,
actully I want to change user in my shell script and want to feed it with password in my shellscipt..... (I do not want to interchange ssl keys ) I am using command echo $password | /bin/sh -u ramesh but when I run the following commands it gives me error of standard in must be a tty can some one please help me regarding this ,I will be delighted Thanks in advance |
Try using su instead - switch user. Something like
Code:
echo $password | su -s -u ramesh |
reply
I am sorry ..I intended to write /bin/su (I mistyped it /bin/sh in my previous post)..... this command is not working for me now I am rewriting the command
echo $password | /bin/su -s -u ramesh its giving me same error as earlier stated |
What precisely are you trying to do? Do you want to execute part of that script as user ramesh, or would you like to open an interactive shell that has ramesh's privileges?
I'd suggest to use sudo. Then you can specify users that are allowed to invoke certain commands as root (or any other user) in /etc/sudoers. |
thanks for reply
I just want to get the interactive shell by this command...... I do not want to use sudo ( I do not have root permission on system either ...) I wish ,if some how I could do it through shell script.... actually I do not want to fill password in password prompt....I will just run the script and it will switch me from my account to ramesh's account ..... ramesh password will be there PASSWORD variable .....and I want to use it to feed the password prompt of su command |
I am pretty sure that one CANNOT do passwd's via a shell - that is why you get this error:
Quote:
I could be wrong (it wouldn't be the first time ;) I guess that you will have to resign yourself to typing in the passwd at the prompt. |
One idea that's just occurred to me: you could initiate an SSH session to the localhost, and set up public key authentication. That way, no password would be asked for. You could issue the commands you needed to as the other user, then log out. To all intents and purposes, it's just another way of starting a shell.
|
All times are GMT -5. The time now is 10:14 AM. |