Spacer http://macenterprise.org MacResource.org - Mac OS X enterprise deployment project Spacer
Site Map Contact Us Top Background
 
Search
 
 
Send UNIX Command Scripts - Pointless ARD Fun E-mail
Written by Steve Hayman   
Tuesday, 07 December 2004

Pointless ARD Fun

osascript <<EOF
set suList to (do shell script "softwareupdate -l") as string
say suList using "Cellos"
EOF

Get the machines to sing the output of some command - in this case, get them to sing the list of software updates we need. Note usage of osascript in order to execute a bit of Applescript. When you type this one in, make sure that the word "EOF" on the last line appears at the beginning of the line. The shell is taking everything from "<<EOF" to the line beginning with "EOF" and feeding it to "osascript" as its input. This usage of "<<" is called a "here document" in shell programming parlance.

Of course you might also use do shell script "date" to get them to sing something simpler. Or skip the shell entirely, and do

osascript <<EOF
	say "Steve needs a vacation" using "Whisper"
EOF
Fun with the Drive Tray

If you have machines - such as G4 iMacs, or G5 towers - with powered drive trays, then the drutil command will be a great source of amusement if you send commands like these to a lab full of machines.

drutil tray open
sleep 1
drutil tray close

Open the tray on all the computers, wait a second, then close it. Don't forget to sleep between the open and the close, or it won't work very well (the machine will start closing the tray before it's fully open.) Once you've got that working, why not try putting it in a loop?

for i in 1 2 3 4 5; do
	drutil tray open
	sleep 1
	drutil tray close
	sleep 1
done

And if you want to get really fancy, rather than having the machines open and close their drive trays in sync, why not insert some delays into the script so that each machine waits a little bit longer than the previous one before opening its tray, thus making the machines do "The Wave". For a movie of this in action, see this clip

Here's the script. You will need to edit the list of machines in the script (the lines after "order" below) to correspond to the names of your machines, in the order in which you'd like them to open and close the tray. The first two variables control the number of times through the loop, and the delay (in microseconds, so 500000 is half a second) between the first machine and the next.

loops=5
factor=500000

me=`systemsetup -getcomputername | sed -e 's/.*: //'`

# Edit this list to reflect the computer names of the machines you have, in the order you want them to do The Wave.

order=`(cat -n <<EOF
Node01
Node02
Node03
Node04
Node05
EOF

)  | grep "$me" | awk '{print $1}' `


for x in `jot $loops`; do
	perl -e "use Time::HiRes qw(usleep); usleep ($order * $factor);"

	drutil tray open
	sleep 1
	drutil tray close

	# Sleep again until a few seconds have gone by so we can get back in sync.

	# note: 2.5 = number of machines / 2
	# if too small, you get a negative time as a result

	perl -e "use Time::HiRes qw(usleep); usleep( 2.5 * $factor * 2 - ($order * $factor)); "

done
Last Updated ( Thursday, 09 December 2004 )
 
< Prev