0

Hi Experts,
Here i am trying to create a script for Auto Back up script to Back up files. files are taking a back up with help of archive zip module along with mentioned the date in corresponding Folder name. Here i am create one xml file for daily updation. BAsed on the date script will be executed at once. which not equal to current date. else back up does not pick bcs same condition which is equal to true. XML file does not get append the daily date.

use strict;
#use File::Copy;
use Archive::Zip;

my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;
$year += 1900;
$mon++;
my $today =  "$mon-$mday-$year";
print $hour-$min;
my $filetobecopied = "test.pl";
my $newfile = "test1.pl";mkdir($today);
mkdir($today);

my $zip = Archive::Zip->new();
$zip->writeToFileNamed("$today/$newfile\.zip"); 


open (WRK, "logfile.xml") || die "Cannot open the input file";
read WRK, my $wrk_xml, -s WRK;
close(WRK);

my $getdate=$1 if ($wrk_xml=~ m{<date>(.*?)</date>});
print $getdate;

my $date_flag;
if($getdate == $today){ $date_flag = 'false';}
else {
    
    $date_flag = 'true';}
 
if($date_flag == 'true'){
print "test";
    
### Prepare ready.xml process . . .
my $ready=<<READY;
<backup-file>
<date>$today</date>
<name>$newfile</name>
</backup-file>

READY
print "test";
open (REA, ">>logfile\.xml") || die "Cannot Open thelog xml file";
print REA $ready; 
close (REA);
}
else
{
print "$hour- $min";    
my $ready=<<READY;
<backup-file>
<date>$today $hour-$min</date>
<name>$newfile</name>
</backup-file>
READY

open (REA, ">>logfile\.xml") || die "Cannot Open thelog xml file";
print REA $ready; 
close (REA);    
}


Advance Thanks,
Senthil. V

Edited by senthilamp4: wrongly put tag

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by k_manimuthu
0

my $today = "$mon-$mday-$year"; , Here $today holds the string values only.
But you are using ( if($getdate == $today), if($date_flag == 'true') ) numerical comparision opertor.

When you want to compare two string use the 'eq' operator.

Edited by k_manimuthu: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.