Helpful Information
 
 
Category: Perl Programming
Filesystem program in Perl - howto

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

yes, use a cron command.

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.

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...

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.










privacy (GDPR)