Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks i am trying to login to a remote windows machine and pull out a log files of yesterday and zip it.The same needs to be transfered to the local machine. And the copied logs of yesterday in the remote machine needs to be deleted. i am using " my $yesterday = strftime "%Y-%m-%d", localtime( time() - ( 24 * 60 * 60 ) ); " to get yesterday's logs. but as it is windlws machine. i am unsure of zippig it and copying the same to local machine. Can any of the monks help on this. Here both the remote and local system are windows based
  • Comment on compress logs based on date and copy to local windows machine

Replies are listed 'Best First'.
Re: compress logs based on date and copy to local windows machine
by bart (Canon) on Apr 03, 2007 at 10:54 UTC
    Are the logs in a shared directory? In that case, you can treat it as a network drive and deal with it as if it was a local file.

    You can also use AT to schedule zipping the file from the command line. How you afterwards fetch it over the network depends on what means you have available.

      Hi Bart Monk The Logs are not in shared directory. Its from a log server from which we have to push to another server.both running windows.
        Then click Start->run, enter \\remote_server\C$, hit return, answer the username/password dialog; open the Log folder in the explorer, right-click->copy, go to your local machine, right-click->paste, zip, copy back. What else?

        Ah, there's Remote Desktop also, which allows you to forward a local directory to the remote server.

        Or install an ssh server on the remote boxes, and do that with pscp.

        --shmem

        _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                      /\_¯/(q    /
        ----------------------------  \__(m.====·.(_("always off the crowd"))."·
        ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

        So....share the directories? Other wise you'll have to setup some other transport, email attachments, ftp...


        ___________
        Eric Hodges
Re: compress logs based on date and copy to local windows machine
by Anonymous Monk on Apr 03, 2007 at 09:43 UTC
    You can use WMI scripts to make this work dude as both are windows mak
Re: compress logs based on date and copy to local windows machine
by Moron (Curate) on Apr 03, 2007 at 17:46 UTC
    The age of a file can be determined using ( -M path ) whereas it's modification date can be extracted using the stat() function.

    I would suggest using Archive::Tar to archive the files into a single file and then Archive::Zip to zip the resulting tar file. These facilities are open-platformed.

    -M

    Free your mind

      Good one Mr.Moron i will certainly give it a try
Re: compress logs based on date and copy to local windows machine
by MonkE (Hermit) on Apr 03, 2007 at 16:20 UTC

    Beware of assuming that all days have 24 hours. Since you are using the localtime() function, most days will have 24 hours as expected, but some days will have 25 hours (autumn DST change), and some days will have 23 hours (spring DST change). This little oversight bit me in back side last year.

    If you run your script just after midnight, your date calculation will be an entire day off when it runs on the morning following the fall DST change.