#!c:\Perl\Bin\Perl.exe use constant EMAIL => 'you@yourdomain.com'; use constant SERVER => 'mail.yourdomain.com'; use IPC::Open3; use Net::SMTP; use strict; my $cmd = join ' ', @ARGV; my $mail = Net::SMTP->new( SERVER ); $mail->to( EMAIL ); $mail->mail( 'root@yourdomain.com' ); $mail->data(); my @output; @output = eval { local *output; open3( "<&STDIN", \*OUTPUT, \*OUTPUT, $cmd ) || die $!; push @::output, $_ while (); close OUTPUT; return @::output; }; if ($@) { $mail->datasend( "The command '$cmd' could not be executed - $@\n" ); } else { $mail->datasend( join('', @output), "\n" ); } $mail->dataend; $mail->quit; exit 0;