#!/usr/bin/perl #become a daemon fork and exit; my $device="/dev/ttyS0"; #set the serial port for 9600,N,8,1 my $str="/bin/stty -F $device ospeed 9600 ispeed 9600 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke"; system("$str"); #print "Watching $device for [SHUTDOWN]...\n"; open(FILE,"<$device"); while () { #print "$_\n"; #watch for [SHUTDOWN] from serial port (Basic Stamp 2) and shutdown if ($_ eq "[SHUTDOWN]\r\n") { exec("/sbin/shutdown -h now"); } }