This problem looks familiar.  What will kill the first snoop?  The while
loop at the bottom assumes snoop is running and tries to run another
snoop on the same interface as the first.  I don't think that can be
done even from the command line because the first snoop will lock
/dev/ge0 (in promiscuous mode).  It will be easier and more robust to
use cron for restarting the process.

-tn

-----Original Message-----
From: rmck [mailto:[EMAIL PROTECTED] 
Sent: Monday, September 29, 2003 9:56 AM
To: [EMAIL PROTECTED]
Subject: Script runs once


Hello,

I have a perl script that is to stop and start at midnight, and write to
a new log file. 

The problem is it runs once then does not run again?? 

Below is the script that I am tring to use?? 


bash-2.03#
#!/bin/perl -w
use warnings;
use strict;
 
my ( $sec, $min, $hour, $day, $mon, $year ) = localtime;
my $snoop   = '/usr/sbin/snoop -d ge0 -ta';
my $date = `date +%W`;
chop($date);
my $dir = "/var/weeks/03_week_$date";

my $logfile = sprintf '/var/weeks/03_week_%d/%02d%02d%02d%02d%02d.sno',
    `date +%W`, $year % 100, $mon + 1, $day, $hour, $min;
 
# create 03_week_dir if does not exist
unless(-d $dir){
mkdir $dir,0660;
} 
 
open LOG, '>', $logfile or die "Cannot open $logfile: $!";
# set default output filehandle and autoflush
select LOG;
$| = 1;
 
print '===============' . localtime . " ==================\n\n";
 
open SNOOP, "$snoop |" or die "Cannot open pipe from $snoop: $!";
 
while ( <SNOOP> ) {
    print;
    # restart this process if midnight
    ( $sec, $min, $hour ) = localtime;
    exec $0 if $sec + $min + $hour == 0;
    }
bash-2.03# 

Thanks,
RM

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


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

Reply via email to