$ cat if-mail.pl #!/usr/bin/perl exit 0 unless (my @lines = ); open(my $mail, "|-", join " ", "/usr/bin/mail", @ARGV) or die $!; print $mail @lines; $ LC_ALL=C ./if-mail.pl root@localhost -s "do not run echo; touch ~/zzz && ls ~/zzz - it does not make sense" TEST ^D ls: cannot access -: No such file or directory ls: cannot access it: No such file or directory ls: cannot access does: No such file or directory ls: cannot access not: No such file or directory ls: cannot access make: No such file or directory ls: cannot access sense: No such file or directory /home/aitap/zzz $ ./if-mail.pl root@localhost -s "try running echo *" TEST ^D