Expecting

Posted on October 19th, 2006 in system administration by Russ

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"

Lazy Programmers?

Posted on October 17th, 2006 in PHP by Russ

I’ve always been of the belief that there’s a basic level of functionality that a web form should present, and after that you can use javascript or even some AJAX (Asynchronous Javascript And XML) to enhance whatever it is you’re working on. For instance, take the index page at my bank’s website. It only has one form on it, for logging into your “internet banking.” But you have to grab your mouse and navigate over to the web form and click on it in order to set the focus there.

How hard would it be to set a JavaScript action on page load- to define a focus on that form element? Sure, it may not help everyone, but it’d certainly help 90 percent of the users (a figure I just pulled out of thin air). It might even help some ADA issues with different mobility options.

In a related note, how many times do I have to type in my city, state and zip code? Many. And there’s javascript or server-side scripts all over the place to confirm that yes, zip code A is valid for City B in state C. But what about the other direction? If you ask the user to type in their zip code, you can automatically populate the city and state, couldn’t you?

That’s the approach I took here.Note, this is a live tool for the Community of Welcoming Congregations; submitting the form won’t be helpful for them. When the page loads, everything is normal. But then when it’s finished, a Javascript fires off that sets the city and state to ‘disabled.’ When the user updates the zip code, the city and state are pulled from the server and stuck into the fields, and the fields are made editable again. If there’s any problem, an alert box pops up asking the user to double check the work.

It wasn’t that much work; I downloaded a zipcode database and wrote the adjoining javascript functions. And it has the possibility of saving the user those few ergs it takes to bang the keyboards; but more importantly, it helps the user with a menial task that could have been solved so much easier.