View Single Post
Old Dec 5th, 2004, 8:49 PM   #1
cyberfunk
Newbie
 
Join Date: Dec 2004
Posts: 2
Rep Power: 0 cyberfunk is on a distinguished road
Hello,

I am trying to run a simple subroutine as part of a script, and I get the following error when I run the program.

Global symbol "$arch_log_dir" requires explicit package name at ./chk_archive_lock.pl line 126.
Execution of ./chk_archive_lock.pl aborted due to compilation errors.

The code to the subroutine is below, and I would appreciate it if someone could show me where I am going wrong, as I am quite new to perl.

I have tried putting a "my" infront of the variable name, but it doesn't seem to work...

Thanks in advance,

Cyber

------------------------------------------------
sub chk_arch_logs_create_time () {

    if ( ! -f $lock ) {

    # Set archive log directory

    if ($hostname eq "hosta001" || $hostname eq "hosta002") {my $arch_log_dir = "/hosta01/oradata/HOSTA/arch";}
    elsif ($hostname eq "hostb001" || $hostname eq "hostbb002") {my $arch_log_dir = "/hostb01/oradata/HOSTB/arch";}
    else { printf "script not running on a valid host...\n"; exit 0; }

        # Check age of archive log files, if > 6 hours old, generate a major USM alarm.

        #while (defined(my $filename = <$arch_log_dir/*>)) {
        while (my $filename = <$arch_log_dir/*>) {

            my $time = time;
            my $attrib = (stat($filename))[9];
            my $arch_age = ($time-$attrib)/3600;

            if ( $arch_age > 6 ) {

            printf USM_LOG "$current_day;$hostname;3773;major;Oracle;$oracle_sid;$oracle_sid Backup not running, & archive logs are $arch_age hours old!\n";

            } else {

            printf USM_LOG "$current_day;$hostname;3773;normal;Oracle;$oracle_sid;$oracle_sid Backups appear to be running. A lock file doesn't exist, and archive logs are only $arch_age hours old.\n";

            }
        }
    }
}

(You've been code tagged! ~ SykkN)
cyberfunk is offline   Reply With Quote