A few days ago I posted a thread to know how to write a script to rotate a log file, and I really appreciate the advises that rharsh and PaulTEG gave me, it help me a lot.
Unfortunately I still have problems to write this script, let me tell you that the script would let me to rotate a file, I mean I have 5 files:
message, message1, message2, message3 and message4
The purpouse of this script is to check for the existance of messages.3 and, if it exists, move its contenst to messages.4. Then is should check for messages.2 and move its contents to messages.3 and so on, until messages is moved to messages.1.
What I understood is writing in the following code :
#! /usr/bin/perl
$mess = "messages";
$mess1 = "messages.1";
$mess2 = "messages.2";
$mess3 = "messages.3";
$mess4 = "messages.4";
if (-e $mess3)
{rename($mess3, $mess4);}
elsif (-e $mess2)
{rename($mess2, $mess3);}
elsif (-e $mess1)
{rename($mess1, $mess2);}
elsif (-e $mess)
{rename($mess, $mess1);}
print $mess1;
To make sure this script worked I write inside messages.3 ;"what's wrong??", and supposedly after running the script I would have this statement inside mess.1, but it didn't happen so I don't know how to solve this problem.
I'm a perl newbie,
Can anybody help me??
thanks in advance
Unfortunately I still have problems to write this script, let me tell you that the script would let me to rotate a file, I mean I have 5 files:
message, message1, message2, message3 and message4
The purpouse of this script is to check for the existance of messages.3 and, if it exists, move its contenst to messages.4. Then is should check for messages.2 and move its contents to messages.3 and so on, until messages is moved to messages.1.
What I understood is writing in the following code :
#! /usr/bin/perl
$mess = "messages";
$mess1 = "messages.1";
$mess2 = "messages.2";
$mess3 = "messages.3";
$mess4 = "messages.4";
if (-e $mess3)
{rename($mess3, $mess4);}
elsif (-e $mess2)
{rename($mess2, $mess3);}
elsif (-e $mess1)
{rename($mess1, $mess2);}
elsif (-e $mess)
{rename($mess, $mess1);}
print $mess1;
To make sure this script worked I write inside messages.3 ;"what's wrong??", and supposedly after running the script I would have this statement inside mess.1, but it didn't happen so I don't know how to solve this problem.
I'm a perl newbie,
Can anybody help me??
thanks in advance