Expect script to ssh a switch
Hi there
I want to login a switch remotely using expect script. Problem arises when I want to pass password. Switch's password Contains a $(dollar)sign. So when I execute the script it shows error, like as follows # ./switchtest spawn ssh root@x.x.x.x root@x.x.x.x's password: can't read "H": no such variable while executing "send " FyPyNyT@$H\r"" (file "./switchtest" line 7) Full Code is as follows ======================= #!/usr/bin/expect set timeout -1 spawn ssh root@x.x.x.x expect "root@x.x.x.x's password:" send " FyPyNyT@$H\r" expect ">" send "enable\r" expect "password:" send " FyPyNyT@$H\r" expect "#" interact My problems: 1. is there any way to pass password in the form of a variable? 2. any way to read password from any text file and send it to switch? I need the code. Thanks in advance. Cheers HASAN |
Hi,
Ref: http://en.wikipedia.org/wiki/Expect Quote:
Looks like you just need to decide how many arguments you would like to provide and then use the appropriate index for your 'host' argument cheers |
Expect Script to ssh a switch
Thanks for the link. But it didn't served my purpose.
Please see my code and mention How I implement this on my code. Thanks anyway. |
Quote:
Code:
"send FyPyNyT\@\$H\r" |
Thanks man. Putting backslash do the trick. :)
|
All times are GMT -5. The time now is 06:14 PM. |