richsark
asked on
Help with EOF error in script
Hello, In this script, I am getting these errors
sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
Can someone look at this and advice
Thanks
sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
Can someone look at this and advice
Thanks
#!perl
use strict;
use warnings;
use Data::Dumper;
open my $log, '>', 'log-external.txt' or die "Could not open log: $!";
print $log "Subnet,Static,DHCP,Unused\n";
open my $dump, '>', 'dump.log' or die "failed to open 'dump.log' $!";
##### Step 1, read subnets
open my $in, '<', 'm-names.txt' or die "Could not open m-names.txt: $!\n";
while( my $subnet = <$in>) {
print "Checking $subnet";
chomp $subnet;
my %counts = (
Static => 0,
DHCP => 0,
Unused => 0,
);
my @dnsoptions = `./getobjectlst.exe -u xx -p xx -o rich -a $subnet 2>&1`;
print $dump "dumping \@dnsoptions\n";
print $dump Data::Dumper->Dump(\@dnsoptions);
print $dump '=' x 25, "\n";
if ( @dnsoptions and $dnsoptions[0] eq '' ) {
print "dnsoptions is null or undefined, going on to the next subnet\n";
next;
}
# Now, at this point, we may have "Error 48" in @dnsoptions, or we may have
# the nicely formatted output. We'll have to check for both cases here.
# Let's check the unsuccessful case first. The condition below checks if
# the first element of @dnsoptions array has the following text in it -
# "Error 48: This subnet does not exist." in it.
if (join("",@dnsoptions) =~ /Error 48: This subnet does not exist./) {
# call "getsubnetlst.exe", passing $subnet as one of the parameters
my @subnetpart2 = `./getsubnetlst.exe -u xx-p xx -o rich -a $subnet -t network`;
print $dump "dumping \@subnetpart2\n";
print $dump Data::Dumper->Dump(\@subnetpart2);
print $dump '=' x 25, "\n";
# now loop through each element of the array @subnetpart2, which looks like this -
# ##########################################################################
# "East" "146.149.1.0" "N" "" "146.149.0.0" " " " " "255.255.255.128"
# ##########################################################################
# pick up the 2nd field from the left (e.g. 146.149.1.0 above), and pass it as
# a parameter to the cli "getobjectlst.exe".
foreach my $line ( @subnetpart2 ) {
# get the 2nd field from the left
my $snetpart2 = (split/"\s+"/, $line)[1];
# and now pass it to "getobjectlst.exe";
my @dnsoptions2 = `./getobjectlst.exe -u xx -p xx -o rich -a $snetpart2`;
print $dump "dumping \@dnsoptions2\n";
print $dump Data::Dumper->Dump(\@dnsoptions2);
print $dump '=' x 25, "\n";
# find out counts of each subnettype (4th field from left)
foreach my $line (@dnsoptions2) {
my @subnettype = split/"\s+"/, $line;
$counts{$subnettype[3]}++;
}
}
}
else { # successful output from getobjectlst.exe
# find out counts of each subnettype (4th field from left)
foreach my $line (@dnsoptions) {
my @subnettype = split/"\s+"/, $line;
$counts{$subnettype[3]}++;
}
}
printf $log "%s,%d,%d,%d\n", $subnet, $counts{Static}, $counts{DHCP}, $counts{Unused};
}
close($in);
close($log);
ASKER
Hi Ozo,
I have a bunch of lines like this:
$ ./getsubnetlst.exe -u xx -p xx -o rich -a 146.149.0.0/16 -t network
"Nat-Bogota-China" "146.149.1.0" "N" "" "146.149.0.0" " " " " "255.255.255.128"
" imported subnet" "146.149.16.0" "Y" "" "146.149.0.0" " " " " "255.255.255.252"
"imported1 subnet" "146.149.16.128" "Y" "" "146.149.0.0" " " " " "255.255.255.240"
When I run this, I have bunch of lines like these:
$ ./getobjectlst.exe -u xx -p xx -o rich -a 146.149.1.0
"146.149.1.1" "" "" "Unused" ""
"146.149.1.2" "" "" "Unused" ""
"146.149.1.3" "" "" "Unused" ""
"146.149.1.4" "" "" "Unused" ""
"146.149.1.5" "" "" "Unused" ""
"146.149.1.6" "" "" "Unused" ""
"146.149.1.7" "" "" "Unused" ""
Does that help?
I have a bunch of lines like this:
$ ./getsubnetlst.exe -u xx -p xx -o rich -a 146.149.0.0/16 -t network
"Nat-Bogota-China" "146.149.1.0" "N" "" "146.149.0.0" " " " " "255.255.255.128"
" imported subnet" "146.149.16.0" "Y" "" "146.149.0.0" " " " " "255.255.255.252"
"imported1 subnet" "146.149.16.128" "Y" "" "146.149.0.0" " " " " "255.255.255.240"
When I run this, I have bunch of lines like these:
$ ./getobjectlst.exe -u xx -p xx -o rich -a 146.149.1.0
"146.149.1.1" "" "" "Unused" ""
"146.149.1.2" "" "" "Unused" ""
"146.149.1.3" "" "" "Unused" ""
"146.149.1.4" "" "" "Unused" ""
"146.149.1.5" "" "" "Unused" ""
"146.149.1.6" "" "" "Unused" ""
"146.149.1.7" "" "" "Unused" ""
Does that help?
which of those lines gets the error?
ASKER
HI Ozo, I would think it starts at line 52 when its doing stuff with teh Error 48
The error message that I got does not tell me which line.
Thanks
The error message that I got does not tell me which line.
Thanks
ASKER
I put it under debug,
see if this provides any clues:
sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
main::(fish3.pl:68): print $dump "dumping \@dnsoptions2\n";
DB<1> n
main::(fish3.pl:69): print $dump Data::Dumper->Dump(\@dnsop tions2);
DB<1> n
main::(fish3.pl:70): print $dump '=' x 25, "\n";
DB<1> n
main::(fish3.pl:73): foreach my $line (@dnsoptions2) {
DB<1> n
main::(fish3.pl:63): my $snetpart2 = (split/"\s+"/, $line)[1];
DB<1> n
main::(fish3.pl:66): my @dnsoptions2 = `./getobjectlst.exe -u x -p x-o rich -a $snetpart2`;
DB<1> n
sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
main::(fish3.pl:68): print $dump "dumping \@dnsoptions2\n";
see if this provides any clues:
sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
main::(fish3.pl:68): print $dump "dumping \@dnsoptions2\n";
DB<1> n
main::(fish3.pl:69): print $dump Data::Dumper->Dump(\@dnsop
DB<1> n
main::(fish3.pl:70): print $dump '=' x 25, "\n";
DB<1> n
main::(fish3.pl:73): foreach my $line (@dnsoptions2) {
DB<1> n
main::(fish3.pl:63): my $snetpart2 = (split/"\s+"/, $line)[1];
DB<1> n
main::(fish3.pl:66): my @dnsoptions2 = `./getobjectlst.exe -u x -p x-o rich -a $snetpart2`;
DB<1> n
sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
main::(fish3.pl:68): print $dump "dumping \@dnsoptions2\n";
may we see what was printed to $dump, and what was in $snetpart2>
ASKER
The dump.log shows
dumping @dnsoptions
$VAR1 = '"10.0.0.1" "" "" "Unused" ""
';
$VAR2 = '"10.0.0.2" "" "" "Unused" ""
';
$VAR3 = '"10.0.0.3" "sarkie-04crp-w04" "Switch" "Static" "netdevice.sark.com"
';
$VAR4 = '"10.0.0.4" "" "" "Unused" ""
';
$VAR5 = '"10.0.0.5" "" "" "Unused" ""
';
$VAR6 = '"10.0.0.6" "rich-ntp-server" "Server" "Static" "netdevice2.sark.com"
';
$VAR254 = '"10.0.0.254" "" "" "Unused" ""
=========================
dumping @dnsoptions
=========================
dumping @dnsoptions
=========================
dumping @dnsoptions
=========================
dumping @dnsoptions
=========================
dumping @dnsoptions
dumping @dnsoptions
$VAR1 = '"10.0.0.1" "" "" "Unused" ""
';
$VAR2 = '"10.0.0.2" "" "" "Unused" ""
';
$VAR3 = '"10.0.0.3" "sarkie-04crp-w04" "Switch" "Static" "netdevice.sark.com"
';
$VAR4 = '"10.0.0.4" "" "" "Unused" ""
';
$VAR5 = '"10.0.0.5" "" "" "Unused" ""
';
$VAR6 = '"10.0.0.6" "rich-ntp-server" "Server" "Static" "netdevice2.sark.com"
';
$VAR254 = '"10.0.0.254" "" "" "Unused" ""
=========================
dumping @dnsoptions
=========================
dumping @dnsoptions
=========================
dumping @dnsoptions
=========================
dumping @dnsoptions
=========================
dumping @dnsoptions
ASKER
for the next part: subnetpart2 which is in the same dump.log
=========================
dumping @dnsoptions
$VAR1 = '146.149.0.0/16
';
$VAR2 = 'getobjectlst.exe :146.149.0.0/16: Error code = 48
';
$VAR3 = 'Error 48: This subnet does not exist.
';
=========================
dumping @subnetpart2
$VAR1 = '"Nat-Colombia" "146.149.1.0" "N" "" "146.149.0.0" " " " " "255.255.255.128"
';
$VAR2 = '"Apogee" "146.149.16.0" "Y" "" "146.149.0.0" " " " " "255.255.255.252"
=========================
dumping @dnsoptions
$VAR1 = '146.149.0.0/16
';
$VAR2 = 'getobjectlst.exe :146.149.0.0/16: Error code = 48
';
$VAR3 = 'Error 48: This subnet does not exist.
';
=========================
dumping @subnetpart2
$VAR1 = '"Nat-Colombia" "146.149.1.0" "N" "" "146.149.0.0" " " " " "255.255.255.128"
';
$VAR2 = '"Apogee" "146.149.16.0" "Y" "" "146.149.0.0" " " " " "255.255.255.252"
may we see what was in $snetpart2 ?
ASKER
Hi, I have shown it above, I guess we crossed posts.
Is that what you are looking for?
Is that what you are looking for?
I don't see where you are dumping \@dnsoptions2\n
If you send both STDERR and $snetpart2 and perhaps $line to $dump we may be able to see which $line is causing the error
If you send both STDERR and $snetpart2 and perhaps $line to $dump we may be able to see which $line is causing the error
where did you show $snetpart2 ?
ASKER
Ok, I put the script in debug and I see that option @dnsoptions2\n";
main::(fish3.pl:63): my $snetpart2 = (split/"\s+"/, $line)[1];
DB<1>
main::(fish3.pl:66): my @dnsoptions2 = `./getobjectlst.exe -u xx -p xx -o rich -a $snetpart2`;
DB<1>
main::(fish3.pl:68): print $dump "dumping \@dnsoptions2\n";
DB<1>
main::(fish3.pl:69): print $dump Data::Dumper->Dump(\@dnsop tions2);
DB<1>
main::(fish3.pl:70): print $dump '=' x 25, "\n";
DB<1>
main::(fish3.pl:73): foreach my $line (@dnsoptions2) {
DB<1>
main::(fish3.pl:74): my @subnettype = split/"\s+"/, $line;
DB<1>
main::(fish3.pl:75): $counts{$subnettype[3]}++;
DB<1>
main::(fish3.pl:74): my @subnettype = split/"\s+"/, $line;
DB<1>
main::(fish3.pl:75): $counts{$subnettype[3]}++;
DB<1>
main::(fish3.pl:74): my @subnettype = split/"\s+"/, $line;
DB<1>
main::(fish3.pl:75): $counts{$subnettype[3]}++;
Is this what you are reffering to? if not please advice
main::(fish3.pl:63): my $snetpart2 = (split/"\s+"/, $line)[1];
DB<1>
main::(fish3.pl:66): my @dnsoptions2 = `./getobjectlst.exe -u xx -p xx -o rich -a $snetpart2`;
DB<1>
main::(fish3.pl:68): print $dump "dumping \@dnsoptions2\n";
DB<1>
main::(fish3.pl:69): print $dump Data::Dumper->Dump(\@dnsop
DB<1>
main::(fish3.pl:70): print $dump '=' x 25, "\n";
DB<1>
main::(fish3.pl:73): foreach my $line (@dnsoptions2) {
DB<1>
main::(fish3.pl:74): my @subnettype = split/"\s+"/, $line;
DB<1>
main::(fish3.pl:75): $counts{$subnettype[3]}++;
DB<1>
main::(fish3.pl:74): my @subnettype = split/"\s+"/, $line;
DB<1>
main::(fish3.pl:75): $counts{$subnettype[3]}++;
DB<1>
main::(fish3.pl:74): my @subnettype = split/"\s+"/, $line;
DB<1>
main::(fish3.pl:75): $counts{$subnettype[3]}++;
Is this what you are reffering to? if not please advice
I saw where you
main::(fish3.pl:68): print $dump "dumping \@dnsoptions2\n";
DB<1> n
main::(fish3.pl:69): print $dump Data::Dumper->Dump(\@dnsop tions2);
nit I only saw
dumping @dnsoptions
not
dumping @dnsoptions2
in the dump log
and we still have no dump of $snetpart2
if you can show $snetpart2 and $line together with STDERR,
we may be able to find the $line that causes the error
main::(fish3.pl:68): print $dump "dumping \@dnsoptions2\n";
DB<1> n
main::(fish3.pl:69): print $dump Data::Dumper->Dump(\@dnsop
nit I only saw
dumping @dnsoptions
not
dumping @dnsoptions2
in the dump log
and we still have no dump of $snetpart2
if you can show $snetpart2 and $line together with STDERR,
we may be able to find the $line that causes the error
ASKER
Hi,
How is this:
main::(fish3.pl:63): my $snetpart2 = (split/"\s+"/, $line)[1];
DB<1>
main::(fish3.pl:66): my @dnsoptions2 = `./getobjectlst.exe -u xx -p xx -o rich -a $snetpart2`;
DB<1>
main::(fish3.pl:68): print $dump "dumping \@dnsoptions2\n";
DB<1>
main::(fish3.pl:69): print $dump Data::Dumper->Dump(\@dnsop tions2);
DB<1>
main::(fish3.pl:70): print $dump '=' x 25, "\n";
DB<1>
main::(fish3.pl:73): foreach my $line (@dnsoptions2) {
DB<1>
main::(fish3.pl:74): my @subnettype = split/"\s+"/, $line;
DB<1>
main::(fish3.pl:75): $counts{$subnettype[3]}++;
DB<1>
main::(fish3.pl:74): my @subnettype = split/"\s+"/, $line;
DB<1>
main::(fish3.pl:75): $counts{$subnettype[3]}++;
DB<1>
main::(fish3.pl:63): my $snetpart2 = (split/"\s+"/, $line)[1];
DB<1>
main::(fish3.pl:66): my @dnsoptions2 = `./getobjectlst.exe -u xx -p xx -o rich -a $snetpart2`;
How is this:
main::(fish3.pl:63): my $snetpart2 = (split/"\s+"/, $line)[1];
DB<1>
main::(fish3.pl:66): my @dnsoptions2 = `./getobjectlst.exe -u xx -p xx -o rich -a $snetpart2`;
DB<1>
main::(fish3.pl:68): print $dump "dumping \@dnsoptions2\n";
DB<1>
main::(fish3.pl:69): print $dump Data::Dumper->Dump(\@dnsop
DB<1>
main::(fish3.pl:70): print $dump '=' x 25, "\n";
DB<1>
main::(fish3.pl:73): foreach my $line (@dnsoptions2) {
DB<1>
main::(fish3.pl:74): my @subnettype = split/"\s+"/, $line;
DB<1>
main::(fish3.pl:75): $counts{$subnettype[3]}++;
DB<1>
main::(fish3.pl:74): my @subnettype = split/"\s+"/, $line;
DB<1>
main::(fish3.pl:75): $counts{$subnettype[3]}++;
DB<1>
main::(fish3.pl:63): my $snetpart2 = (split/"\s+"/, $line)[1];
DB<1>
main::(fish3.pl:66): my @dnsoptions2 = `./getobjectlst.exe -u xx -p xx -o rich -a $snetpart2`;
ASKER
Another attempt
63: my $snetpart2 = (split/"\s+"/, $line)[1];
64
65 # and now pass it to "getobjectlst.exe";
66==> my @dnsoptions2 = `./getobjectlst.exe -u xx -p xx -o rich -a $snetpart2`;
67
68: print $dump "dumping \@dnsoptions2\n";
69: print $dump Data::Dumper->Dump(\@dnsop tions2);
70: print $dump '=' x 25, "\n";
71
72 # find out counts of each subnettype (4th field from left)
63: my $snetpart2 = (split/"\s+"/, $line)[1];
64
65 # and now pass it to "getobjectlst.exe";
66==> my @dnsoptions2 = `./getobjectlst.exe -u xx -p xx -o rich -a $snetpart2`;
67
68: print $dump "dumping \@dnsoptions2\n";
69: print $dump Data::Dumper->Dump(\@dnsop
70: print $dump '=' x 25, "\n";
71
72 # find out counts of each subnettype (4th field from left)
can you show $snetpart2 together with the error message?
ASKER
hi ozo, I ran the script with perl -d script_name.pl
I dont see that EOF error message. What am I doing wrong, or what is the best way to get this produced?
I dont see that EOF error message. What am I doing wrong, or what is the best way to get this produced?
if you are no longer getting the error messages, does that mean it is fixed?
ASKER
Hi,
No, I just cant seem to see it under debug, but when I run it normally, I see it on the screen
No, I just cant seem to see it under debug, but when I run it normally, I see it on the screen
ASKER
Ok, I got something
main::(fish3.pl:43): if (join("",@dnsoptions) =~ /Error 48: This subnet does not exist./) {
DB<1>
main::(fish3.pl:46): my @subnetpart2 = `./getsubnetlst.exe -u xx -p xx -o rich -a $subnet -t network`;
DB<1>
main::(fish3.pl:48): print $dump "dumping \@subnetpart2\n";
DB<1>
main::(fish3.pl:49): print $dump Data::Dumper->Dump(\@subne tpart2);
DB<1>
main::(fish3.pl:50): print $dump '=' x 25, "\n";
DB<1>
main::(fish3.pl:61): foreach my $line ( @subnetpart2 ) {
DB<1>
main::(fish3.pl:64): my $snetpart2 = (split/"\s+"/, $line)[1];
DB<1>
main::(fish3.pl:67): my @dnsoptions2 = `./getobjectlst.exe -u xx -p xx -o rich -a $snetpart2`;
DB<1>
sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
main::(fish3.pl:69): print $dump "dumping \@dnsoptions2\n";
DB<1>
main::(fish3.pl:70): print $dump Data::Dumper->Dump(\@dnsop tions2);
DB<1>
main::(fish3.pl:71): print $dump '=' x 25, "\n";
main::(fish3.pl:43): if (join("",@dnsoptions) =~ /Error 48: This subnet does not exist./) {
DB<1>
main::(fish3.pl:46): my @subnetpart2 = `./getsubnetlst.exe -u xx -p xx -o rich -a $subnet -t network`;
DB<1>
main::(fish3.pl:48): print $dump "dumping \@subnetpart2\n";
DB<1>
main::(fish3.pl:49): print $dump Data::Dumper->Dump(\@subne
DB<1>
main::(fish3.pl:50): print $dump '=' x 25, "\n";
DB<1>
main::(fish3.pl:61): foreach my $line ( @subnetpart2 ) {
DB<1>
main::(fish3.pl:64): my $snetpart2 = (split/"\s+"/, $line)[1];
DB<1>
main::(fish3.pl:67): my @dnsoptions2 = `./getobjectlst.exe -u xx -p xx -o rich -a $snetpart2`;
DB<1>
sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
main::(fish3.pl:69): print $dump "dumping \@dnsoptions2\n";
DB<1>
main::(fish3.pl:70): print $dump Data::Dumper->Dump(\@dnsop
DB<1>
main::(fish3.pl:71): print $dump '=' x 25, "\n";
can you print $snetpart2
where the error appears?
where the error appears?
ASKER
Ok,
$ perl fish3.pl
Checking 162.2.0.0/16 "162.2.1.0sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
"162.2.2.0sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
"162.2.3.0sh: -c: line 0: unexpected EOF while looking for matching `"'
$ perl fish3.pl
Checking 162.2.0.0/16 "162.2.1.0sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
"162.2.2.0sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
"162.2.3.0sh: -c: line 0: unexpected EOF while looking for matching `"'
ASKER
A bit more:
3798"162.2.28.252Unused"
3799"162.2.28.253Unused"
3800"162.2.28.254Unused"
3801 "162.2.29.0sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
"162.2.30.0sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
"162.2.31.0sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
"162.2.32.0sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
"162.2.35.0sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
"162.2.36.0sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
"162.2.37.0sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
"162.2.38.0sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
"162.2.39.0sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
"162.2.40.0sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
"162.2.43.0sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
"162.2.44.0sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
"162.2.45.0sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
"162.2.46.0sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
"162.2.51.0sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
"162.2.52.0sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
"162.2.53.0sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
"162.2.54.0sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
"162.2.80.0sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
162.2.81.0"162.2.81.1" "" "" "Unused" ""
"162.2.81.2" "" "" "Unused" ""
"162.2.81.3" "" "" "Unused" ""
"162.2.81.4" "" "" "Unused" ""
3798"162.2.28.252Unused"
3799"162.2.28.253Unused"
3800"162.2.28.254Unused"
3801 "162.2.29.0sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
"162.2.30.0sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
"162.2.31.0sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
"162.2.32.0sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
"162.2.35.0sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
"162.2.36.0sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
"162.2.37.0sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
"162.2.38.0sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
"162.2.39.0sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
"162.2.40.0sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
"162.2.43.0sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
"162.2.44.0sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
"162.2.45.0sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
"162.2.46.0sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
"162.2.51.0sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
"162.2.52.0sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
"162.2.53.0sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
"162.2.54.0sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
"162.2.80.0sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
162.2.81.0"162.2.81.1" "" "" "Unused" ""
"162.2.81.2" "" "" "Unused" ""
"162.2.81.3" "" "" "Unused" ""
"162.2.81.4" "" "" "Unused" ""
was any of that $snetpart2 or $line?
ASKER
Yes;
foreach my $line ( @subnetpart2 ) {
# get the 2nd field from the left
print my $snetpart2 = (split/"\s+"/, $line)[1];
# and now pass it to "getobjectlst.exe";
print my @dnsoptions2 = `./getobjectlst.exe -u xx -p xx -o rich -a $snetpart2`;
print $dump "dumping \@dnsoptions2\n";
print $dump Data::Dumper->Dump(\@dnsop tions2);
print $dump '=' x 25, "\n";
# find out counts of each subnettype (4th field from left)
foreach my $line (@dnsoptions2) {
print my @subnettype = split/"\s+"/, $line;
print $counts{$subnettype[3]}++;
foreach my $line ( @subnetpart2 ) {
# get the 2nd field from the left
print my $snetpart2 = (split/"\s+"/, $line)[1];
# and now pass it to "getobjectlst.exe";
print my @dnsoptions2 = `./getobjectlst.exe -u xx -p xx -o rich -a $snetpart2`;
print $dump "dumping \@dnsoptions2\n";
print $dump Data::Dumper->Dump(\@dnsop
print $dump '=' x 25, "\n";
# find out counts of each subnettype (4th field from left)
foreach my $line (@dnsoptions2) {
print my @subnettype = split/"\s+"/, $line;
print $counts{$subnettype[3]}++;
what part of the output came from the
print my $snetpart2 = (split/"\s+"/, $line)[1];
print my $snetpart2 = (split/"\s+"/, $line)[1];
if it was the
"162.2.30.0
that has an unmatched " that could explain the error
"162.2.30.0
that has an unmatched " that could explain the error
ASKER
I dont understand sir
if the print my $snetpart2 = (split/"\s+"/, $line)[1];
is what printed the
"162.2.30.0
it would mean that $snetpart2 eq '"162.2.30.0'
and that you were executing
`./getobjectlst.exe -u xx -p xx -o rich -a "162.2.30.0`
which has no match for the "
is what printed the
"162.2.30.0
it would mean that $snetpart2 eq '"162.2.30.0'
and that you were executing
`./getobjectlst.exe -u xx -p xx -o rich -a "162.2.30.0`
which has no match for the "
ASKER
ok, so how can we fix it not to show the error?, or is it not an issue to have it display
ASKER
ahh.. so we have a " somewhere that needs to come out, or recode that line right?
If so, can you be so kind to provide that please.
Thanks
If so, can you be so kind to provide that please.
Thanks
if the print my $snetpart2 = (split/"\s+"/, $line)[1];
is what printed the
"162.2.30.0
then I'm wondering what $line was
since it may indicate that it did not look the way you expected it to.
But if you wanted to execute
./getobjectlst.exe -u xx -p xx -o rich -a 162.2.30.0
rather than
./getobjectlst.exe -u xx -p xx -o rich -a "162.2.30.0
then you would need to remove the "
is what printed the
"162.2.30.0
then I'm wondering what $line was
since it may indicate that it did not look the way you expected it to.
But if you wanted to execute
./getobjectlst.exe -u xx -p xx -o rich -a 162.2.30.0
rather than
./getobjectlst.exe -u xx -p xx -o rich -a "162.2.30.0
then you would need to remove the "
ASKER
ok, so how can we re-write it to either ignore it or do something else with it?
print my $snetpart2 = (split/"\s+"/, $line)[1];
if( $snetpart2 =~ /"/ ){
warn "\$snetpart iwas $snetpart\nwhen \$line was $line";
next;
}
#or, if the only problem was an extra ", you might just $snetpart2 =~s/"//g;
if( $snetpart2 =~ /"/ ){
warn "\$snetpart iwas $snetpart\nwhen \$line was $line";
next;
}
#or, if the only problem was an extra ", you might just $snetpart2 =~s/"//g;
ASKER
Ok, I added:
my $snetpart2 =~s/"//g;
Checking 162.2.0.0/16Use of uninitialized value $snetpart2 in substitution (s///) at fish3.pl line 64, <$in> line 1
Use of uninitialized value $snetpart2 in concatenation (.) or string at fish3.pl line 68, <$in> line 1.
my $snetpart2 =~s/"//g;
Checking 162.2.0.0/16Use of uninitialized value $snetpart2 in substitution (s///) at fish3.pl line 64, <$in> line 1
Use of uninitialized value $snetpart2 in concatenation (.) or string at fish3.pl line 68, <$in> line 1.
If there was no "\s+" in $line, then (split/"\s+"/, $line)[1] would be undef
if you said
my $snetpart2 =~s/"//g;
the my would create a new variable that would not contain anything that came from
print my $snetpart2 = (split/"\s+"/, $line)[1];
my $snetpart2 =~s/"//g;
the my would create a new variable that would not contain anything that came from
print my $snetpart2 = (split/"\s+"/, $line)[1];
ASKER
Ok, so the complete code looks like;
adding this:
my $snetpart2 = (split/"\s+"/, $line)[1];
adding this:
my $snetpart2 = (split/"\s+"/, $line)[1];
#!perl
use strict;
use warnings;
use Data::Dumper;
open my $log, '>', 'log-external.txt' or die "Could not open log: $!";
print $log "Subnet,Static,DHCP,Unused\n";
open my $dump, '>', 'dump.log' or die "failed to open 'dump.log' $!";
##### Step 1, read subnets
open my $in, '<', 'm-names.txt' or die "Could not open m-names.txt: $!\n";
while( my $subnet = <$in>) {
print "Checking $subnet";
chomp $subnet;
my %counts = (
Static => 0,
DHCP => 0,
Unused => 0,
);
my @dnsoptions = `./getobjectlst.exe -u xx -p xx -o rich -a $subnet 2>&1`;
print $dump "dumping \@dnsoptions\n";
print $dump Data::Dumper->Dump(\@dnsoptions);
print $dump '=' x 25, "\n";
if ( @dnsoptions and $dnsoptions[0] eq '' ) {
print "dnsoptions is null or undefined, going on to the next subnet\n";
next;
}
# Now, at this point, we may have "Error 48" in @dnsoptions, or we may have
# the nicely formatted output. We'll have to check for both cases here.
# Let's check the unsuccessful case first. The condition below checks if
# the first element of @dnsoptions array has the following text in it -
# "Error 48: This subnet does not exist." in it.
if (join("",@dnsoptions) =~ /Error 48: This subnet does not exist./) {
# call "getsubnetlst.exe", passing $subnet as one of the parameters
my @subnetpart2 = `./getsubnetlst.exe -u xx-p xx -o rich -a $subnet -t network`;
print $dump "dumping \@subnetpart2\n";
print $dump Data::Dumper->Dump(\@subnetpart2);
print $dump '=' x 25, "\n";
# now loop through each element of the array @subnetpart2, which looks like this -
# ##########################################################################
# "East" "146.149.1.0" "N" "" "146.149.0.0" " " " " "255.255.255.128"
# ##########################################################################
# pick up the 2nd field from the left (e.g. 146.149.1.0 above), and pass it as
# a parameter to the cli "getobjectlst.exe".
foreach my $line ( @subnetpart2 ) {
# get the 2nd field from the left
my $snetpart2 = (split/"\s+"/, $line)[1];
# and now pass it to "getobjectlst.exe";
my @dnsoptions2 = `./getobjectlst.exe -u xx -p xx -o rich -a $snetpart2`;
print $dump "dumping \@dnsoptions2\n";
print $dump Data::Dumper->Dump(\@dnsoptions2);
print $dump '=' x 25, "\n";
# find out counts of each subnettype (4th field from left)
foreach my $line (@dnsoptions2) {
my @subnettype = split/"\s+"/, $line;
$counts{$subnettype[3]}++;
}
}
}
else { # successful output from getobjectlst.exe
# find out counts of each subnettype (4th field from left)
foreach my $line (@dnsoptions) {
my @subnettype = split/"\s+"/, $line;
$counts{$subnettype[3]}++;
}
}
printf $log "%s,%d,%d,%d\n", $subnet, $counts{Static}, $counts{DHCP}, $counts{Unused};
}
close($in);
close($log);
ASKER
If that is the case, I am still getting the bloddy EOF
Checking 162.2.0.0/16
sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
Checking 162.2.0.0/16
sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
If what is the case?
what is in $snetpart2 when you get that error?
what is in $snetpart2 when you get that error?
ASKER
HI, Also, I cant figure out how to format the output
From this:
Subnet,Static,DHCP,Unused
10.0.0.0/8
,37,0,217
146.149.0.0/16
To this:
Subnet,Static,DHCP,Unused
10.0.0.0/8,37,0,217
146.149.0.0/16,174,0,39314
From this:
Subnet,Static,DHCP,Unused
10.0.0.0/8
,37,0,217
146.149.0.0/16
To this:
Subnet,Static,DHCP,Unused
10.0.0.0/8,37,0,217
146.149.0.0/16,174,0,39314
ASKER
I used this part:
my $snetpart2 = (split/"\s+"/, $line)[1];
if( $snetpart2 =~ /"/ ){
warn "\$snetpart2 i was $snetpart2\nwhen \$line was $line";
next;
}
Seems to work; now I get messages like:
when $line was " " "162.2.201.0" "N" "Enterprise Management LAN" "162.2.0.0" "EMEA-" " " "255.255.255.0"
$snetpart2 i was "162.2.240.0
when $line was " " "162.2.240.0" "N" "Enterprise Management LAN" "162.2.0.0" "EMe" " " "255.255.255.0"
$snetpart2 i was "162.2.241.0
when $line was " " "162.2.241.0" "N" "Enterprise Management LAN" "162.2.0.0" "Usa-" " " "255.255.255.0"
Checking 162.5.0.0/16
What does this mean?
warn "\$snetpart2 i was $snetpart2\nwhen \$line was $line";
Focusing on "i was" and "nwhen"
my $snetpart2 = (split/"\s+"/, $line)[1];
if( $snetpart2 =~ /"/ ){
warn "\$snetpart2 i was $snetpart2\nwhen \$line was $line";
next;
}
Seems to work; now I get messages like:
when $line was " " "162.2.201.0" "N" "Enterprise Management LAN" "162.2.0.0" "EMEA-" " " "255.255.255.0"
$snetpart2 i was "162.2.240.0
when $line was " " "162.2.240.0" "N" "Enterprise Management LAN" "162.2.0.0" "EMe" " " "255.255.255.0"
$snetpart2 i was "162.2.241.0
when $line was " " "162.2.241.0" "N" "Enterprise Management LAN" "162.2.0.0" "Usa-" " " "255.255.255.0"
Checking 162.5.0.0/16
What does this mean?
warn "\$snetpart2 i was $snetpart2\nwhen \$line was $line";
Focusing on "i was" and "nwhen"
#!perl
use strict;
use warnings;
use Data::Dumper;
open my $log, '>', 'log-external.txt' or die "Could not open log: $!";
print $log "Subnet,Static,DHCP,Unused\n";
open my $dump, '>', 'dump.log' or die "failed to open 'dump.log' $!";
##### Step 1, read subnets
open my $in, '<', 'm-names.txt' or die "Could not open m-names.txt: $!\n";
while( my $subnet = <$in>) {
print "Checking $subnet";
chomp $subnet;
my %counts = (
Static => 0,
DHCP => 0,
Unused => 0,
);
my @dnsoptions = `./getobjectlst.exe -u xx -p xx -o rich -a $subnet 2>&1`;
print $dump "dumping \@dnsoptions\n";
print $dump Data::Dumper->Dump(\@dnsoptions);
print $dump '=' x 25, "\n";
if ( @dnsoptions and $dnsoptions[0] eq '' ) {
print "dnsoptions is null or undefined, going on to the next subnet\n";
next;
}
# Now, at this point, we may have "Error 48" in @dnsoptions, or we may have
# the nicely formatted output. We'll have to check for both cases here.
# Let's check the unsuccessful case first. The condition below checks if
# the first element of @dnsoptions array has the following text in it -
# "Error 48: This subnet does not exist." in it.
if (join("",@dnsoptions) =~ /Error 48: This subnet does not exist./) {
# call "getsubnetlst.exe", passing $subnet as one of the parameters
my @subnetpart2 = `./getsubnetlst.exe -u xx-p xx -o rich -a $subnet -t network`;
print $dump "dumping \@subnetpart2\n";
print $dump Data::Dumper->Dump(\@subnetpart2);
print $dump '=' x 25, "\n";
# now loop through each element of the array @subnetpart2, which looks like this -
# ##########################################################################
# "East" "146.149.1.0" "N" "" "146.149.0.0" " " " " "255.255.255.128"
# ##########################################################################
# pick up the 2nd field from the left (e.g. 146.149.1.0 above), and pass it as
# a parameter to the cli "getobjectlst.exe".
foreach my $line ( @subnetpart2 ) {
# get the 2nd field from the left
my $snetpart2 = (split/"\s+"/, $line)[1];
if( $snetpart2 =~ /"/ ){
warn "\$snetpart2 i was $snetpart2\nwhen \$line was $line";
next;
}
# and now pass it to "getobjectlst.exe";
my @dnsoptions2 = `./getobjectlst.exe -u xx -p xx -o rich -a $snetpart2`;
print $dump "dumping \@dnsoptions2\n";
print $dump Data::Dumper->Dump(\@dnsoptions2);
print $dump '=' x 25, "\n";
# find out counts of each subnettype (4th field from left)
foreach my $line (@dnsoptions2) {
my @subnettype = split/"\s+"/, $line;
$counts{$subnettype[3]}++;
}
}
}
else { # successful output from getobjectlst.exe
# find out counts of each subnettype (4th field from left)
foreach my $line (@dnsoptions) {
my @subnettype = split/"\s+"/, $line;
$counts{$subnettype[3]}++;
}
}
printf $log "%s,%d,%d,%d\n", $subnet, $counts{Static}, $counts{DHCP}, $counts{Unused};
}
close($in);
close($log);
DB<5> $line='" " "162.2.201.0" "N" "Enterprise Management LAN" "162.2.0.0" "EMEA-" " " "255.255.255.0"'
DB<6> x (split/"\s+"/, $line)
0 ''
1 ' "162.2.201.0'
2 'N'
3 'Enterprise Management LAN'
4 '162.2.0.0'
5 'EMEA-'
6 ' '
7 '255.255.255.0"'
DB<7> x (split/"\s+"/, $line)[1]
0 ' "162.2.201.0'
DB<6> x (split/"\s+"/, $line)
0 ''
1 ' "162.2.201.0'
2 'N'
3 'Enterprise Management LAN'
4 '162.2.0.0'
5 'EMEA-'
6 ' '
7 '255.255.255.0"'
DB<7> x (split/"\s+"/, $line)[1]
0 ' "162.2.201.0'
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok, can you please comment on the format output above please
ASKER
Thanks for your help Ozo !
I would of never thought of that ( at least this year )
my $snetpart2 = (split/"\s+"/, $line)[1];
if( $snetpart2 =~ /"/ ){
warn "\$snetpart2 i was $snetpart2\nwhen \$line was $line";
next;
}
Before I close this out, is there a way I could get you to see why I cant get the format right.
I would like the output from the log-external.txt
from this:
Subnet,Static,DHCP,Unused
10.0.0.0/8
,37,0,217
146.149.0.0/16
To this:
Subnet,Static,DHCP,Unused
10.0.0.0/8,37,0,217
146.149.0.0/16,174,0,39314
I tried to play with the line
printf $log "%s,%d,%d,%d\n", $subnet, $counts{Static}, $counts{DHCP}, $counts{Unused};
I tried this:
printf $log "%s,%d,%d,%d,%d\n", $subnet, $subnet, $counts{Static}, $counts{DHCP}, $counts{Unused};
And:
printf $log "%s,%d,%d,%d\n", $subnet, $subnet\n $counts{Static}, $counts{DHCP}, $counts{Unused};
Any thoughts?
I would of never thought of that ( at least this year )
my $snetpart2 = (split/"\s+"/, $line)[1];
if( $snetpart2 =~ /"/ ){
warn "\$snetpart2 i was $snetpart2\nwhen \$line was $line";
next;
}
Before I close this out, is there a way I could get you to see why I cant get the format right.
I would like the output from the log-external.txt
from this:
Subnet,Static,DHCP,Unused
10.0.0.0/8
,37,0,217
146.149.0.0/16
To this:
Subnet,Static,DHCP,Unused
10.0.0.0/8,37,0,217
146.149.0.0/16,174,0,39314
I tried to play with the line
printf $log "%s,%d,%d,%d\n", $subnet, $counts{Static}, $counts{DHCP}, $counts{Unused};
I tried this:
printf $log "%s,%d,%d,%d,%d\n", $subnet, $subnet, $counts{Static}, $counts{DHCP}, $counts{Unused};
And:
printf $log "%s,%d,%d,%d\n", $subnet, $subnet\n $counts{Static}, $counts{DHCP}, $counts{Unused};
Any thoughts?
ASKER
good work
It looks like $subnet has a "\n" at the end, which is strange, since the chomp $subnet; should have removed it, and a "\n" in $subnet should have caused a problem for `./getsubnetlst.exe -u xx-p xx -o rich -a $subnet -t network`
`./getsubnetlst.exe -u xx-p xx -o rich -a $subnet -t network`
what is in $snetpart2 when you do
`./getobjectlst.exe -u xx -p xx -o rich -a $snetpart2`