Hey all,
Okay, here's some background on this. I wrote a script (to replace an
older batch file) for an NT server. The purpose of this script is to shut
down a service, then move three files to another directory, and add the
date to the end of the filename (ex. foo-20010709.log). Now, when I
tested the script on my computer, it works fine (and I set it up similarly
to the server it needs to go on). The catch with this program, is that it
has to put the day of the month as the previous day (for example, the
program would run at 12:01am on the 10th, but the filename of the log
would have to be the 9th). I've also run this program on a test server,
which is exactly like the production box, and it runs fine; however if I
schedule it to do the same thing, it doesn't work (using the AT
scheduler).
If anyone could provide some insight, I'd apprecate it:
#!/usr/bin/perl -w
# CME FIX Log mover
# This script will move the CME log files and place the correct working
date
# on the logfile
use strict;
use File::Copy;
# This section defines the different logfiles
my $event = "68100FIXSOM681Aevnt";
my $send = "68100FIXSOM681Asend";
my $recv = "68100FIXSOM681Arecv";
# This sets up the values for the $date variable
(my $sec, my $min, my $hour, my $mday, my $mon, my $year, my $wday, my
$yday, my $isdst) = localtime(time);
# This calls a subroutine that handles file moving at the end of the month
# so that the file for 20010630 doesn't become 20010700 for example
($mon,$mday) = &datefix($mon,$mday);
# This sets up the value of $date that we will use in the new name of the
# logfile
my $date = sprintf("%d%02d%02d", $year+1900, $mon, $mday);
# This shuts down the two services so we can move the log file
system("net stop NetProbe") or print "Couldn't stop NetProbe service
$!\n";
# This puts us in the right directory
chdir("d:\\glsofts\\slecmea\\log");
# These lines move the respective log files to the old directory
move ("$event.log", "d:\\glsofts\\slecmea\\log\\old\\$event-$date.log");
move ("$send.log", "d:\\glsofts\\slecmea\\log\\old\\$send-$date.log");
move ("$recv.log", "d:\\glsofts\\slecmea\\log\\old\\$recv-$date.log");
# Here we start the services back up again
system("net start NetProbe") or print "Couldn't start NetProbe service
$!\n";
# This is the subroutine that handles the last day of the month
sub datefix {
my ($month,$day) = @_;
# If the day is 1, that means we just ended a month, so if the current
month is
# not May, July, October, or December set the day value to 30
if ($day <= 1 && $month !~ /[5,7,10,12]/)
{
$day = 30;
print "This is the first option $day\n";
return($month,$day);
# If the month is February, set the day value to 28
} elsif ($day <= 1 && $month =~ /2/)
{
$day = 28;
print "This is the second option $day and $month\n";
return($month,$day);
# This handles the months that have 31 days
} elsif ($day <= 1 && $month =~ /[5,7,10,12]/)
{
$day = 31;
print "This is the third option $day and $month\n";
return($month,$day);
} else
# This handles the rest of the days of the month. Note we have to
increment the
# $month value, because by default it is returned as the current month - 1
{
$day = $day - 1;
$month += 1;
return ($month,$day);
}
}
Thanks ahead of time for the help,
Tom
--
#!/usr/bin/perl -w # 526-byte qrpff, Keith Winstein and Marc Horowitz
<[EMAIL PROTECTED]> # MPEG 2 PS VOB file on stdin -> descrambled output
on stdout # arguments: title key bytes in least to most-significant order
$_='while(read+STDIN,$_,2048){$a=29;$c=142;if((@a=unx"C*",$_)[20]&48){$h=5;
$_=unxb24,join"",@b=map{xB8,unxb8,chr($_^$a[--$h+84])}@ARGV;s/...$/1$&/;$d=
unxV,xb25,$_;$b=73;$e=256|(ord$b[4])<<9|ord$b[3];$d=$d>>8^($f=($t=255)&($d
>>12^$d>>4^$d^$d/8))<<17,$e=$e>>8^($t&($g=($q=$e>>14&7^$e)^$q*8^$q<<6))<<9
,$_=(map{$_%16or$t^=$c^=($m=(11,10,116,100,11,122,20,100)[$_/16%8])&110;$t
^=(72,@z=(64,72,$a^=12*($_%16-2?0:$m&17)),$b^=$_%64?12:0,@z)[$_%8]}(16..271))
[$_]^(($h>>=8)+=$f+(~$g&$t))for@a[128..$#a]}print+x"C*",@a}';s/x/pack+/g;eval