== A little script: _sshup_ (It's been a while since [[the last little script LittleScriptsVI]].) One of the things I do a fair bit around [[here http://www.cs.toronto.edu/]] is reboot machines. Well, to be more specific, I reboot machines and then wait for them to come back up so that I can continue my testing, do more work on them, or verify that everything is fine. Because I am not crazy I do not do this in the machine room; I do it from my desk. Waiting for machines to come up and checking periodically to see if they have is tedious, repetitive, and boring. Like any lazy sysadmin, I long ago automated this in a handy little script that I call _sshup_. Since what I care about is when I can ssh in to newly-rebooted machines, the script tests to see if a machine is up by checking to see if it can connect to the machine's ssh port. (You can do this with netcat; the version of the script that I actually use is written in rc and uses a different netcat-like utility program for reasons that don't fit in this margin.) I generally run _sshup_ in an _xterm_ with [[zIconBeep set XtermZiconbeep]]; start a new _xterm_, run _sshup_, iconify it, and do something else until either the iconified _xterm_ notifies me that the machine is up (because _sshup_ printed something) or I realize that too much time has passed and go look into what's wrong. It's turned out to be quite handy. Here is a version of _sshup_ in Bourne shell: #!/bin/sh # usage: sshup host reachable() { nc -z $1 ssh; } while ! reachable $1; do sleep 15 done echo $1 UP (A real version would have some error checking and maybe not hard-code the sleep interval.)