How to send Two different password in Single script, having same username..?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to send Two different password in Single script, having same username..?
# 1  
Old 03-23-2015
How to send Two different password in Single script, having same username..?

Hi Team,
i want to input two password for single node like pass1/pass2 one of the pass1 is working some node and pass2 is working for some nodes .
For nodes having pass1 i have to run different script and
for nodes having pass2 i have to run different script

Sooo
how can put two pass (Pass1/pass2)option in single script..

I m using.

1st script is like........
Code:
#!/usr/bin/expect
spawn telnet $ip
expect "login:"
send "USR\r"
expect "*assword*"
send "pass1\r"
expect "*$"


2nd script is like........
Code:
#!/usr/bin/expect
spawn telnet $ip
expect "login:"
send "USR\r"
expect "*assword*"
send "pass1\r"
expect "*$"


i want both pass1&pass2 option in single script , how can i do it????
# 2  
Old 03-23-2015
Not sure I understand your setup nor request.

What keeps you from copying the scripts together into one and put an if/then or select decision upfront to run either?

Last edited by RudiC; 03-23-2015 at 01:09 PM..
# 3  
Old 03-23-2015
Is ssh a possibility here? Telnet is kind of thorny to use at the best of times. For ssh, I think you could just install two keys and ssh would try each for you and be done with it.
# 4  
Old 03-23-2015
I think in your case you just need two variables, each holding the appropriate password rather than having the password hardcoded in the scripts. Does that make sense? Also, if these two scripts are to be called from (let's say) another script, maybe the password for each comes in from the command line?

Of course, nothing about this setup is very secure at all. If you wanted something more secure then perhaps the scripts could read the appropriate passwords from a very controlled file? Still not great, but possibly better than exposing the password all over the place.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

To send ID and Password for each command using expect feature in bash script

Dear Tech Guys, I am trying to send some commands on the local server and it always asks for user name and password after each command. To serve the purpose I am using expect function as follows: #!/usr/bin/expect set timeout 20 spawn "./data1.sh" expect "Please Enter UserName: "... (6 Replies)
Discussion started by: Xtreme
6 Replies

2. Shell Programming and Scripting

Passing Username & password through shell script to java code

Hi, I have a shell script (script.sh) in which we are calling java code which asks for Username: Password: for authentication purpose currently we are passing the credential manually and run the script. but I am trying echo -e "user_id\npassword" | script.sh but its not... (1 Reply)
Discussion started by: rakeshtomar82
1 Replies

3. Shell Programming and Scripting

Script to send an email for password expiry

Newbie in scripting Please assist with a script to send an email to all users seven days before their passwords expires.Aging set for 90 days. # chage -l user1 Last password change : Jul 08, 2015 Password expires :... (4 Replies)
Discussion started by: tshepang
4 Replies

4. UNIX for Dummies Questions & Answers

Script to log in SFTP server [with username, password]

Hi, everyone, I am trying to write a script to login automatically using username and password to an sftp server (the key authentication has been disabled so I cannot use that method). I tried to search online for a solution and found a way using "expect" but my boss does not want me to use... (4 Replies)
Discussion started by: warmboy610
4 Replies

5. Shell Programming and Scripting

Passing username and password to a script running inside "expect" script

Hi I'm trying to run a script " abc.sh" which triggers "use.sh" . abc.sh is nothing but a "expect" script which provides username and password automatically to the use.sh script. Please find below the scripts: #abc.sh #!/usr/bin/expect -f exec /root/use.sh expect "*name*" send... (1 Reply)
Discussion started by: baddykam
1 Replies

6. Shell Programming and Scripting

Asking username and password in the middle of the Shell/perl script

Can any body help me to find out the logic I have a script chkcomponent.pl Which give some output Like component1 userid: u1 component2 userid: u2 component3 userid: u1 . . #The no of components are different in different times run Now I want this chkcomponent.pl script... (1 Reply)
Discussion started by: pareshpatra
1 Replies

7. Shell Programming and Scripting

Read Oracle Username password SID from single file and pass it to shell

Dear All I am trying to write one shell which will be running through Cron which contain one SQL query. But I want to draw/fetch the Username password and Instance name (required to loging to the database) from one single file to run that SQL query . Also this file contain details of multiple... (2 Replies)
Discussion started by: jhon
2 Replies

8. Shell Programming and Scripting

Need to write script to send an email for password reset.

Hi all, Please suggest I want to write a scritp which will send a email to my mail address before the time duration of the password reset, Should write mail stating that your password will expire in so and so days"" Rgds:b: Ann. (2 Replies)
Discussion started by: Haque123
2 Replies

9. Solaris

i wanto hardcode password for a username to ssh to a server using script

Dear all i want to ssh to a server via running a shell script with a username and i want to hard code the password for that particular username can u help me please Thank u Naree (8 Replies)
Discussion started by: naree
8 Replies

10. Shell Programming and Scripting

username password in script

Can we write a script to telnet to a unix server from unix with the username and password hardcoded in the script?? something like ssh a@b -p password ??? (5 Replies)
Discussion started by: roshanjain2
5 Replies
Login or Register to Ask a Question