• Expecting

    by  • 19 October 2006 • system administration • 0 Comments

    As part of two positions, I often have to reboot a remote system, on a remote power server. I mean ‘power cycle,’ not just reboot. What this entails is telnetting into a remote server, and walking through a predictible set of menus and commands. I finally gave up and scripted it; I used ‘expect’ because it was, frankly, the easiest.

    ‘Expect’ is used to mimic a series of commands. It’s a scripting language like PHP or Perl, but older, and it has a different syntax. It’s also related to Tcl (tickle) programming… Here’s the example. Use it as you’d like; I’m sure there’s more ways to make it work (it’d be nice to add more options, so I can use the same script to reboot several servers).

    set timeout 60
    spawn telnet ip address
    expect "User Name*"
    send "username\r"
    expect "Password*"
    send "password\r"
    expect ">"
    send "1\r"
    expect ">"
    send "1\r"
    expect ">"
    send "1\r"
    expect ">"
    send "3\r"
    expect "cancel*"
    send "YES\r"


    I was seduced by the dot-com promises of high profits and fun work environments. I became dissillusioned and left the company after learning PHP and MySQL and Linux administration (I started with Slackware). The knowledge was a reasonable trade for not being paid for several months. I enjoy helping people get their presence on the web- I'm good with e-commerce, data scraping and repurposing, and general day-to-day management. I'm a creative thinker with a passion for creating useful ways to view information. I live in Portland Oregon with my lovely wife and two daughters. We have cats, dogs, and an overgrown yard.


    Leave a Reply

    Your email address will not be published. Required fields are marked *