#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2000
    Location
    Calcutta, West Bengal, India
    Posts
    25
    Rep Power
    0
    I want to write a small program in perl that will check a particular directory in the Linux filesystem and copy a file (if it exists) and transfer to another directory over the network.

    This perl program should be checking the directory every 5 minutes (or xx minutes). Should I CRON this program ?

    Please help, I will be very pleased since I am new to this Perl world and got to get this solved.

    Thanks in advance
  2. #2
  3. SwollenMember
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Location
    the master control
    Posts
    264
    Rep Power
    15
    yes, use a cron command.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2000
    Location
    Calcutta, West Bengal, India
    Posts
    25
    Rep Power
    0
    Thanks for the help on the CRON part. I also need help on the Perl program part to chek the directory and either copy or FTP to another directory aor FTP directory

    Thanks in advance.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    300
    Rep Power
    15
    I'm not sure what you wish to do, but if you wish to see ifa file exists, and then copy it to another directory, simply use this:
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    if (-e $somefile){
    system("cp $somefile $destionation");
    }
    [/code]

    If you want to copy this file to another FTP server, use the Net:FTP module, available from CPAN...

  8. #5
  9. No Profile Picture
    freebsd
    Guest
    Devshed Newbie (0 - 499 posts)
    The BEST way, however, is to use "rsync" -> ftp://sunsite.auc.dk/pub/unix/rsync/ which should do exactly what you wanted efficiently.
    It's highly customizable, you can even ignore certain files, keeping original timestamp and permission and so.

IMN logo majestic logo threadwatch logo seochat tools logo