syntax error at D:\plscipts\fwimport.pl line 44, near "sub nameimport " Global symbol "@name" requires explicit package name at D:\plscipts\fwimport.pl line 47. Execution of D:\plscipts\fwimport.pl aborted due to compilation errors. #### #!/bin/perl -W # This script is for the importing of Pix firewall configs. # This script requires Acitve Perl with the DBI module # and DBD module for ODBC. Also a user DSN needs to be made for # the FWexcept database to be used named FW. # # This script is for internal use, it has not been built to # production standards. There are no input or performance # sanity checks. # # For the sake of my sanity I'm continuing to use my naming standard # for DBI functions. For database handles the convention is "(name)db" # where (name) is the database name. For all SQL commands the # convention is "name""table""SQL command type", where the table is # the table/s names and "SQL command type" is qry, ins, upd, or del. use strict; use DBI; # get the firewall config, submited as an argument # the config will be passed to the script as the array @config if (/$ARGV[0]/) { open (CONFIG,"$ARGV[0]") || die "Could not open $ARGV[0]\n"; my @config = ; close (CONFIG); } # connect to the DSN on the local system database handles end in db my $FWdb = DBI->connect('DBI:ODBC:FW'); # Build insert statement for the exception table my $FWexceptioninst = $FWdb->prepare(q(INSERT INTO Exception(access-list,acl-name,firewallID,Interface,server,Active) VALUES (?,?,?,?,?,Yes))); # Build insert statement for the firewall table my $FWfirewallinst = $FWdb->prepare(q(INSERT INTO firewalls(FW-Name,Type,SW-revision,ContactID-PriWAN,ContactID-SecWAN,ContactID-ISSO) VALUES (?,PIX,?,2,3,1))); # Build query of the FirewalID assigned by the database my $FWfirewallqry = $FWdb->prepare(q(SELECT FirewallID FROM firewalls WHERE FW-name = ?)) # The routine imports basic information about the firewall into the firealls table. # It assumes that the firewall is administratied by Foo and Bar by the WAN team, # and Baz in the ISSO. It returns the hostname of the firewall and the FirewallID. sub nameimport { foreach (@_) { if (/hostname/) { local @name = split(/ /); } elsif (/version/) { local @version = split(/ /); }; }; $FWfirewallsinst->execute($name[1],$version[2]); $FWdb->commit; $FWfirewallsqry->execute($name[1]); @FWfirewallsinfo = $FWfirewallsqry->fetchrow_array; # print "$FWfirewallsinfo[0]\n"; return ($FWfirewallsinfo[0],$name[1]); } # The routine imports the acls into the Exception table. # It requires the $FWID global var is set to the FirewallID in the database. # The local var $aclimport keeps track of the number of successfully imported rules. # It assumes that all rules imported are active. Output is the number of rules imported. sub acl { local $aclimport = 0; local $part = ""; foreach (@_) { if (/access-list/) { local @acl = split(/ /); foreach $part (@acl) { if ($part =~ /192\.35\.84\./) {local $server = $part}; }; local $interface = $acl[1] =~ s/acl-//; local @importinfo = (q($_,$acl[1],$FWID,$interface,$server)); $FWexecptionins->execute(@importinfo) && $aclimport++; }; }; return scalar($aclimport); }; # If the firewall name has been supplied then get the FirewallID otherwise assume new config if (/$ARGV[1]/) { $FWfirewallsqry->execute($ARGV[1]); @FWfirewallsinfo = $FWfirewallsqry->fetchrow_array; my $FWID = $FWfirewallsinfo[0]; my $FWname = $ARGV[1]; } else { my ($FWID,$FWname) = nameimport(@config); }; my $aclimport = acl(@config); print "The script has successfully imported $aclimport rules for $FWname.\n";