Hi Rob,

You don't need to put the system call in backticks. You could just do
        $result = `some command`;
to get the output of the command stored as a multiline string in $result.

system() does not store the output of the command, only the exit status of 
the command you have called.

I don't think you need to combine both at the same time at all.

hth,
deen    

On Mon, 28 Jan 2002, McCormick, Rob E wrote:

> Gang,
> 
> Using 'df -k' in bash, I can get this to work acceptably:
> 
> # mail the disk usage for a file system to a recipient 'uid'
> df -k /data/wrc |mailx -s 'host disk usage' [EMAIL PROTECTED]
> 
> I'd like to use perl to surround the output of df -k with a simple text
> message.  I used perldoc -q mail to find the code to use sendmail, but I'd
> like to extend the sendmail example slightly.  My attempt below:
> 
> ----------------------
> #!/usr/bin/perl -w
> use strict;
> 
> my $results = system (`/usr/bin/df -k`);
> # backticks seem to be working OK?
> 
> open(SENDMAIL, "|/usr/lib/sendmail -oi -t")
>         or die "Can't fork for sendmail: $!\n";
> print SENDMAIL <<"EOF";
> From: <uid\@host>
> To: <email_acct\@acme.com>
> Subject: host disk usage
> 
> host disk usage
> print "$results\n";
> EOF
> close (SENDMAIL) or warn "sendmail didn't close nicely";
> ---------------------------
> 
> The error condition that occurs: mail is created and sent, I receive it, but
> the content of the mail is:
> 
> host disk usage
> print "65280
> ";
> 
> Any corrections you could offer that don't involve a module?
> Or is it best to install a module?
> 
> Thanks,
> Rob
> 
> 
> 
> 
> 
> 

-- 
Deen Hameedd, Accidental Programmer [EMAIL PROTECTED]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to