#!/usr/bin/perl -w use IO::Socket; # adjust to your needs! $host = "IP address"; $port = 23; $user = "owner name"; $passwd = "owner's password"; $| = 1; # otherwise <$sock> will wait forever on Mac $/ = "\012"; $sock = new IO::Socket::INET(PeerAddr => $host, PeerPort => $port, Proto => 'tcp', Timeout => 10); die "IO::Socket::INET $!" unless $sock; $sock->autoflush(1); if ( defined($line = <$sock>) ) { $line =~ tr/\x0A/\x0D/ if $^O =~/MacOS/; print "\nWait a moment...\n" } print $sock "$user\x0A\x0D"; sleep 1; print $sock "$passwd\x0A\x0D"; sleep 1; print $sock "/EXEC\x0A\x0D"; sleep 1; print $sock "tell application \"Finder\" to shut down\x0A\x0D"; sleep 1; print $sock ".\x0A\x0D"; sleep 1; close($sock); print "\n...machine shut down succesfully\n"; exit( 0 );