1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
   | #!c:\\perl\\bin\\perl
## Script d'import/export vers test.net
 
use Archive::Tar;
use Win32;
use File::Copy;
use Time::Local;
 
my $dest_dir="D:\\Program Files\\test.net\\website\\fichiers";
my $ifacedir="D:\\Program Files\\test.net\\website";
my $arch_file;
my $time=localtime (time);
my @t=localtime (time);
my $day=$t[3];
my $month=$t[4]+1;
my $year=$t[5]+1900;
my $log="D:\\Program Files\\test.net\\scripts\\logs\\mgnet-$day.$month.$year.log";
 
open (LOG,">>$log");
 
print LOG "### Debut : $time\n";
 
### On verifie la presence du fichier transfert
print LOG "\nRecherche du/des fichiers \"transfert\"\n";
sort my @transfiles=<$dest_dir\\transfert*.tar>;
my $nfiles=@transfiles;
 
if ( $nfiles eq 0 ) {
	print LOG "**** -> Aucun fichier transfert\n"; }
elsif ( $nfiles gt 1 ) {
	print LOG "\tATTENTION : il y a $nfiles fichiers a integrer\n"; }
 
foreach  ( @transfiles ) {
	$arch_file=$_;
	print LOG "Traitement de : $arch_file\n";
 
	my $tar=Archive::Tar->new();
 
	### On lit l'archive en memoire
	### le param 1 signifie que l'archive est compressee
	$tar->read($arch_file,1) or print LOG "Archive $arch_file corrompue\n" and exit 2;
 
	my @files=$tar->list_files(); | 
Partager