Yanet I wrote:
> 
> Hello all,

Hello,

> I have been having a bit of trouble with a script that is very easy to
> develop in ksh.  I am just trying to rotate logs.
> 
> some of the variables I declare are:
>         my $LOGDIR=/some/where/in/my/file/system/logdir;
>         my $LOG=/some/where/in/my/file/system/logdir/logtorotate;

You need to enclose strings in quotes:

my $logdir = '/some/where/in/my/file/system/logdir';
my $log    = '/some/where/in/my/file/system/logdir/logtorotate';


> I have an array containing the name of the logs I want to rotate:
>         my @alllogs=qw(log.0 log.1 log.2 log.3);
> 
> I want to accomplish the following:
> I want to go to $LOGDIR (HOW DO I GO TO THAT DIRECTORY FROM MY SCRIPT W/OUT
> USING A system(".....") call?)

chdir $logdir or die "Cannot chdir to $logdir: $!";


> and make sure that those files exist.

perldoc -f -e


> After that I want to   mv $log.2 $log.3
>                        mv $log.1 $log.2
>                        mv $log.0 $log.1

rename 'log.2', 'log.3' or die "Cannot rename 'log.2': $!";


> once again, how do I do this without using a system call (iff possible?).
> then,  I want to mv $LOG $log.0  and lastly I want to clear the
> contents of $LOG, (I would normally do cp /dev/null $LOG or $LOG)

truncate $log, 0 or warn "Cannot truncate $log: $!";


perldoc -f chdir
perldoc -f -X
perldoc -f rename
perldoc -f truncate


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to