Results 1 to 5 of 5

Thread: Perl script - monitoring a directory

  1. #1

    Thread Starter
    Frenzied Member SomethinCool's Avatar
    Join Date
    Jan 2001
    Location
    Malvern, PA
    Posts
    1,407

    Perl script - monitoring a directory

    Does anyone know how to create a perl script or a bash script (whichever works the best) that monitors a specific directory and then copies the NEW files and directories that were created since the last check? Is it possible to do this?

    For instance, if i have a directory with a bunch of text documents in a bunch of different folders that sits on the server and then on a computer it has the same folders and files but the computer files will be updated. The server is a backup server. So the the program checks to see what directories and files are there. Then the next check it notices 2 new folders and 10 files compared to the backup directory on the server. It should then copy the files and folders from the computer machine to the backup folder on the server.

  2. #2
    PowerPoster sunburnt's Avatar
    Join Date
    Feb 2001
    Location
    Boulder, Colorado
    Posts
    1,403

    Re: Perl script - monitoring a directory

    This sounds like a perfect use case for rsync.

    rsync will synchronize the contents of two directories (possibly on different machines), copying only what has changed between the two.

    basically, you say:

    Code:
    rsync -av /source/dir@source /dest@dest
    which synchronizes copies the (updated) contents of the directory /source/dir on the computer source to the directory /dest on the computer 'dest'.

    Check the man pages or google for more information.
    Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.

  3. #3

    Thread Starter
    Frenzied Member SomethinCool's Avatar
    Join Date
    Jan 2001
    Location
    Malvern, PA
    Posts
    1,407

    Re: Perl script - monitoring a directory

    Well the one machine is a windows machine, so am I going to have to run an rsync server on that machine or could i just mount the samba share to a directory like /mnt/smb and sync the two directories locally on the machine?

  4. #4
    Frenzied Member tr333's Avatar
    Join Date
    Nov 2004
    Location
    /dev/st0
    Posts
    1,605

    Re: Perl script - monitoring a directory

    Unison is a file synchronization program based on the rsync algorithm and runs on linux/mac/windows/solaris. I have found it to be easy to use in my experience with it.
    CSS layout comes in to the 21st century with flexbox!
    Just another Perl hacker,

  5. #5
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: Perl script - monitoring a directory

    I second that. I use unison on Network shares, multiple OS'es and to update websites in a production environment along with change management tools.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width