The below Perl snippet keeps giving me prototype mismatch errors. The script
runs via command line to change the wins entries.
____ ERRORS ____
Prototype mismatch: sub main::NULL () vs none at (eval 1) line 5.
Constant subroutine NULL redefined at (eval 1) line 5.
Prototype mismatch: sub main::WIN31_CLASS () vs none at (eval 1) line 6.
Subroutine WIN31_CLASS redefined at (eval 1) line 6.
Prototype mismatch: sub main::OWNER_SECURITY_INFORMATION () vs none at (eval
1)
line 183.
Constant subroutine OWNER_SECURITY_INFORMATION redefined at (eval 1) line
183.
Prototype mismatch: sub main::GROUP_SECURITY_INFORMATION () vs none at (eval
1)
line 184.
Constant subroutine GROUP_SECURITY_INFORMATION redefined at (eval 1) line
184.
Prototype mismatch: sub main::DACL_SECURITY_INFORMATION () vs none at (eval
1) l
ine 185.
Constant subroutine DACL_SECURITY_INFORMATION redefined at (eval 1) line
185.
Prototype mismatch: sub main::SACL_SECURITY_INFORMATION () vs none at (eval
1) l
ine 186.
Constant subroutine SACL_SECURITY_INFORMATION redefined at (eval 1) line
186.
____ END ERRORS ____
Any suggestions greatly appreciated.
Steve
#!/Perl -w
# To update a local machine, enter.
# c:\>perl winser.pl <xxx.xxx.xxx.xxx> <xxx.xxx.xxx.xxx>
#
# To update a remote machine, enter.
# c:\>perl winser.pl <xxx.xxx.xxx.xxx> <xxx.xxx.xxx.xxx> remote <hostname>
#
# To update multiple machines, enter.
# c:\>perl winser.pl <xxx.xxx.xxx.xxx> <xxx.xxx.xxx.xxx> file <filename>
use Win32;
use strict;
require 'NT.ph';
use vars qw(@machines $machine $key_LM $key_Adapters $i $adaptername
$key_Adapter);
# The below looks for command line args, or it will print the sub help.
(@ARGV) or &PrintHelp;
# Let's grab the command line args in either $primary and/or $secondary.
my $primary = $ARGV[0];
my $secondary = $ARGV[1];
# Now Perl is looking for the 3rd argument, if entered, it is a remote
# machine.
if ($ARGV[2]) {
if (lc($ARGV[2]) eq "remote") {
@machines = ($ARGV[3]);
} elsif (lc($ARGV[2]) eq "file") {
open(FILELIST, "<$ARGV[3]") or
die "Unable to read file $ARGV[3] for list of ".
"computernames.\n";
@machines = grep(/\S/, map {s/\s//g; $_} <FILELIST>);
close FILELIST;
} else {
die "Third command line option $ARGV[2] illegal.\n";
}
} else {
@machines = ($ENV{COMPUTERNAME});
}
foreach $machine (@machines) {
unless (Win32::RegConnectRegistry($machine,
&HKEY_LOCAL_MACHINE, $key_LM)) {
print "$machine: ERROR, unable to connect to ".
"remote registry.\n";
next;
}
unless (Win32::RegOpenKeyEx($key_LM,
"SYSTEM\\CurrentControlSet\\Services\\NetBT\\Adapters",
&NULL, &KEY_ALL_ACCESS, $key_Adapters)) {
print "$machine: ERROR, unable to connect to open ".
"NetBT\\Adapters.\n";
Win32::RegCloseKey($key_LM);
next;
}
$i = 0;
while (Win32::RegEnumKey($key_Adapters, $i++,
$adaptername)) {
($adaptername =~ /NdisWan/i) and next;
unless (Win32::RegOpenKeyEx($key_Adapters, $adaptername,
&NULL, &KEY_ALL_ACCESS, $key_Adapter)) {
print "$machine: ERROR, unable to connect to open ".
"NetBT\\Adapters\\$adaptername.\n";
next;
}
unless (Win32::RegSetValueEx($key_Adapter, "NameServer",
&NULL, ®_SZ, $primary)) {
print "$machine: ERROR, unable to set primary WINS ".
"address or $adaptername.\n";
Win32::RegCloseKey($key_Adapter);
next;
}
unless (Win32::RegSetValueEx($key_Adapter,
"NameServerBackup", &NULL, ®_SZ, $secondary)) {
print "$machine: ERROR, unable to set secondary WINS ".
"address for $adaptername.\n";
Win32::RegCloseKey($key_Adapter);
next;
}
print "$machine: Set primary and secondary WINS ".
"addresses to $primary and $secondary for ".
"adapter $adaptername.\n";
Win32::RegCloseKey($key_Adapters);
}
Win32::RegCloseKey($key_LM);
}
sub PrintHelp {
print <<END;
This program is designed to update the WINS entries on either the
local host, a remote host, or a list of remote hosts. In all
cases, the first two parameters are the desired primary and
secondary WINS server IP addresses. In the local host case, pass
no more parameters. In the remote host case, pass the string
"remote" (no quotes) followed by a space and the hostname. In the
list of remote hosts case, pass the string "file" (no quotes)
followed by the name of a file containing one hostname per line.
In all cases, the program will return information about whether
it was successful.
END
exit;
}
_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
- RE: Updating wins problem steve silvers
- RE: Updating wins problem Stanley . G . Martin