When I'm away on the weekend, I like to know what's been happening on my network. I used the Net::SMTP to have my Wintel machines email me as soon as the user Logs on. What I've done is not original and as soon as I finished this snippet, I've thought of other uses for this little trick. Big thanks to St. Larry and Company.
#! perl -w # fn_with_me.pl # A quick and dirty way to tell if someone is messing with My Computer +s use Net::SMTP; use Sys::Hostname; $host = hostname; $smtp = Net::SMTP -> new('your.mailhost.net'); #Connect to a mail serv +er $smtp -> mail( 'anysender@theirmailhost.net'); #Sender's name $smtp -> to('myemail@mymailhost.net'); #Receivers name $smtp -> data(); # Send the header $smtp -> datasend("To: myemail\@mymailhost.net\n"); $smtp -> datasend("From: theiremail\@mymailhost.net\n"); $smtp -> datasend("\n"); # Send the Body $smtp -> datasend("Somebody's using ".$host); $smtp -> dataend(); $smtp -> quit;

Replies are listed 'Best First'.
RE: Watching my Users
by httptech (Chaplain) on Jun 18, 2000 at 15:47 UTC
    It might also be useful to know who is using the machine:
    #! perl -w # fn_with_me.pl # A quick and dirty way to tell if someone is messing with My Computer +s use Net::SMTP; use Sys::Hostname; use Win32; $host = hostname; $user = Win32::LoginName(); $smtp = Net::SMTP -> new('your.mailhost.net'); #Connect to a mail serv +er $smtp -> mail( 'anysender@theirmailhost.net'); #Sender's name $smtp -> to('myemail@mymailhost.net'); #Receivers name $smtp -> data(); # Send the header $smtp -> datasend("To: myemail\@mymailhost.net\n"); $smtp -> datasend("From: theiremail\@mymailhost.net\n"); $smtp -> datasend("\n"); # Send the Body $smtp -> datasend("$user is using $host"); $smtp -> dataend(); $smtp -> quit;
      Thanks for the comment. I've inherited this system from a previous sysadmin and his policy was very loose. Once I implement my new security measures, I'll be able to extract the user name from their login. When I fix the code, I'll repost.