in reply to capture output and email on linux

Please understand that I'm not currently in the position to test what I'm writing below, but you can get the idea.

If you mandatorily want to use mail or mailx, you'd probably do that using the shell instead of Perl:

#!/bin/bash while read command ; do rsh $command snapmirror status done <netapps 2>&1 | mail foo@example.com
or something like that (I don't know the mail program).

OTOH, Perl has a plethora of modules dealing with e-mail, which you can find on http://www.cpan.org (or, better, on http://search.cpan.org), among which I've used Jenda's Mail::Sender which I find both simple and effective. If you can go with a full-Perl solution, you have to get rid of the system call and use the backtick operator or its equivalent qx operator; in this case perlop will help you but it should more or less sound like this:

#!/usr/bin/perl use strict; use warnings; open IN, "<", "netapps" || die "Can't open file"; my $output = ''; while (<IN>) { chomp; $output .= qx( rsh $_ snapmirror status 2>&1 ); }
Note the redirection to be sure to grab both stdout and stderr. Now $output should hold both of them from all commands, and you can send it by email.

As a final note, be absolutely sure that you trust the netapps file, otherwise you will have bad, bad surprises.

Update: removed backslash inside qx()

Flavio (perl -e 'print(scalar(reverse("\nti.xittelop\@oivalf")))')

Don't fool yourself.