LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 06-09-2006, 02:22 AM   #1
shashwat.gupta
LQ Newbie
 
Registered: May 2006
Posts: 18

Rep: Reputation: 0
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
 
Old 06-09-2006, 03:28 AM   #2
cdhgee
Member
 
Registered: Oct 2003
Location: St Paul, MN
Distribution: Fedora 8, Fedora 9
Posts: 513

Rep: Reputation: 30
Try using su instead - switch user. Something like

Code:
echo $password | su -s -u ramesh
Don't quote me on the exact specifics, but something like this ought to work.
 
Old 06-09-2006, 03:51 AM   #3
shashwat.gupta
LQ Newbie
 
Registered: May 2006
Posts: 18

Original Poster
Rep: Reputation: 0
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
 
Old 06-09-2006, 04:10 AM   #4
spirit receiver
Member
 
Registered: May 2006
Location: Frankfurt, Germany
Distribution: SUSE 10.2
Posts: 424

Rep: Reputation: 33
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.
 
Old 06-09-2006, 04:34 AM   #5
shashwat.gupta
LQ Newbie
 
Registered: May 2006
Posts: 18

Original Poster
Rep: Reputation: 0
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
 
Old 06-10-2006, 03:55 AM   #6
worzel68
Member
 
Registered: May 2006
Location: Sydney
Distribution: FC5, FC3, AIX, System V,
Posts: 50

Rep: Reputation: 15
I am pretty sure that one CANNOT do passwd's via a shell - that is why you get this error:

Quote:
standard in must be a tty
A passwd must typed from the keyboard -it's one of the basic security features of any linux/unix.

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.
 
Old 06-14-2006, 01:42 AM   #7
cdhgee
Member
 
Registered: Oct 2003
Location: St Paul, MN
Distribution: Fedora 8, Fedora 9
Posts: 513

Rep: Reputation: 30
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell script to change password kamal_aitin Linux - General 6 07-25-2007 12:09 AM
How to tell shell script a password? Etoile Linux - Newbie 5 04-05-2006 09:16 PM
Setting password for users in a shell script?? krishvij Linux - Newbie 3 03-10-2005 09:17 AM
Shell Script For Password cpope67 Programming 4 01-10-2005 02:16 AM
Password Shell Script Solaris 9 cpope67 Solaris / OpenSolaris 1 12-30-2004 03:15 PM


All times are GMT -5. The time now is 09:31 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration