Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

move () stumped

move () stumped

move () stumped

Happy New Year Guru's! :)

I am having a problem with my script renaming/moving files
the move() and also tried rename() doesn't seem to like the .gz
after i compress the file.  when i run the script it gives


Any thoughts?

Here is what I am doing:

$A_Log = "$A.log";
$B_Log = "$B.log";

my @files = ( $A_Log, $B_Log );

foreach $logFile (sort(@files)) {
      print "$logFile\n"; #debug
      if ( -e $logFile ) {
           $fsize = (stat($logFile))[7];
            if ( $fsize >= 5000000 ) {    
                  system("/bin/gzip -9 $logFile");
                  print "$logFile\n"; #debug
                  move( $logFile.gz, $logFile.(strftime '%Y%m%d%H%M%S%Z', localtime time).gz ) or die "Could not move gzip'd file $logFile: $!\n";
                  print "info: $logFile compressed and moved...\n";

            else {
                  print "info: $logFile does not need to be moved...\n";
      else {
            print "info: $logFile does not exist\n";

} # End foreach Loop


RE: move () stumped


Quote (grazinggoat):

doesn't seem to like the .gz
A concatenation operator and a bareword ? I agree with Perl, neither I like that.

CODE --> Perl ( fragment )

move( $logFile.'.gz', $logFile.(strftime '%Y%m%d%H%M%S%Z', localtime time).'.gz' )
As I have no idea from where that strftime comes, I did not tested the code.


RE: move () stumped

Ahhh.. Noted Feherke on the concatenation and bareword!  I'm coming along thought!
Thank you, Sir! :)

My turn to share with you....
As for strtime.. It's from calling POSIX module.

strtime - Convert date and time information to string. Returns the string.

RE: move () stumped


Quote (grazinggoat):

As for strtime.. It's from calling POSIX module.
Ah, right. perldoc.perl.org's search engine returns "No matches found" in all categories when searching for "strftime". Thanks, next time I will use Google instead.


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close