Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2013
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Ignore special characters in bash/expect script

    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
    Last edited by meirh; 01-03-2013 at 04:17 PM.




  2. #2
    Join Date
    Oct 2012
    Location
    Minsk, Belarus
    Posts
    15
    Thanks
    0
    Thanked 3 Times in 3 Posts
    Rep Power
    0
    Try "\\\$toor\\r"

  3. The Following User Says Thank You to old_bolvan For This Useful Post:

    meirh (01-04-2013)

  4. #3
    Join Date
    Jan 2013
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    Quote Originally Posted by old_bolvan View Post
    Try "\\\$toor\\r"

    Work lile a dream! thanks a lot!!

 

 

Similar Threads

  1. Basic Backup Script in BASH
    By ehansen in forum Linux-Howtos
    Replies: 16
    Last Post: 02-12-2013, 09:05 AM
  2. Build your own special characters chooser
    By News in forum Linux News
    Replies: 0
    Last Post: 03-06-2012, 01:14 AM
  3. Basic Backup Script in BASH
    By News in forum Linux News
    Replies: 0
    Last Post: 01-26-2012, 10:19 PM
  4. Replies: 0
    Last Post: 01-10-2012, 10:21 AM
  5. Replies: 0
    Last Post: 01-10-2012, 09:51 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
           








Check out Linux Central for Linux software and other goodies!





» Stats

Members: 3,588
Threads: 3,921
Posts: 9,451
Top Poster: Fred (1,486)
Welcome to our newest member, newtolinux

» Links



Powered by vBadvanced CMPS