• Rob's side project: I recently started Gun-Forums.com and we currently have a $100 raffle - if you're into guns, join up and enter the raffle to win $100.00. Gun Forums

Ignore special characters in bash/expect script

M

meirh

Guest
Hi all, first of all, great forum, i have reading here a lot :)

My question:
I'm trying to write script that part of is job is to do telnet session to switch with expect commands.
everything is ok except the password issu, my switches password is $toor, and $ is variable character, to resolve it, im writing it like that:
$\toor, the problem is in expect "\t" is also special characters :~, you know \t \r \n those are special characters in expect.
i tried 1000 of variation to how to write it right, i have tried $\toor , $\\toor , \$toor , \$\toor and other option but nothing have worked..

does anyone are know how to resolve it?

thats the command:
/usr/bin/expect -d <<EOF > cdp.txt

spawn telnet $switchip ;
expect "Username:" ;
send "root\r" ;
expect "Password" ;
send "$toor\r" ;
expect "#" ;
send "sh cdp neighbors detail $portnumber \r"
expect "#"
send "logout\n" ;
EOF


Thank you vry much, i have tried any possible variation, please help :)
 




Members online


Latest posts

Top