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


In reply to Glob problem by wylie

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.