wylie has asked for the wisdom of the Perl Monks concerning the following question:
Thanks to everyone who has helped me with this so far.
I want to search for a file named weekly in a series of sub-directories. If the file exists I want to gzip two log files and email them to someone.
The file glob works now (thanks Hofmator and others!) but the $a variable doesn't appear to be being processed in the $msg->build section of the code that creates the email messages.
I get this error message when I run the script.
/home/www/abc/logs gzip: /access_log: No such file or directory gzip: /error_log: No such file or directory /home/www/def/logs gzip: /access_log: No such file or directory gzip: /error_log: No such file or directory
What is the problem? Thanks in advance.
#!/usr/bin/perl -w use strict; use diagnostics; use MIME::Lite; #use a file glob in a for loop to search for marker file "weekly" # added braces and changed variable name for my $a (</home/www/*/logs/weekly>) { substr($a,-7)=" "; print $a; #build a mail message with the access_log & error log files gzipp'ed #and attached my $msg = MIME::Lite->build( From => 'root@abc.xyz.com', To => 'john.doe@joesoap.org', Subject => "gzipp'ed log file", Type =>'x-gzip', Path =>"/usr/bin/gzip < $a/access_log |", ReadNow => 1, Filename =>"access_log.tgz"); $msg->send; my $msg2 = MIME::Lite->build( From => 'root@abc.xyz.com', To => 'john.doe@joesoap.org', Subject => "gzipp'ed log file", Type =>'x-gzip', Path =>"/usr/bin/gzip < $a/error_log |", ReadNow => 1, Filename =>"error_log.tgz"); $msg2->send; }
Edit Masem 2001-08-21 - Code tags added, extra CRs removed
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Glob problem
by Hofmator (Curate) on Aug 21, 2001 at 15:32 UTC | |
by wylie (Novice) on Aug 21, 2001 at 16:34 UTC | |
|
Re: Glob problem
by Zaxo (Archbishop) on Aug 21, 2001 at 15:22 UTC | |
by Hofmator (Curate) on Aug 21, 2001 at 15:34 UTC | |
by wylie (Novice) on Aug 21, 2001 at 15:34 UTC |