Sorry for top posting but makes this easier...  Comments are in your
code below.  Mostly you forgot semicolons in your code and used = when
you needed eq.  BTW, I have not tested any of this, just spotted some
things.

HTH!!
Bill

-----Original Message-----
From: Mark VanMiddlesworth [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, February 11, 2003 7:23 PM
To: [EMAIL PROTECTED]
Subject: Help getting scripts working...

this is a script that systematically pings every host on the network, 
and writes the output to the screen. If the -n arg is specified, it 
will also write to a disk. What's wrong with the syntax, especially 
line 12?

#!/usr/bin/env perl
$x = 1;
$b = 0;
         for ($x = 1; $x < 256; $x++) {
                 $a = `ping -q -c 1  192.168.1.$b`;
                 $b += 1;
                 print "192.168.1.$b   ";
                 print $a;
                 $usage="ping.pl [-n]"
Should be: $usage="ping.pl [-n]";
(No terminating semicolon, also you define $usage but don't use it
anywhere.)

                 if ($arg = "-n") {$e = 0}
Should be: if ($arg eq "-n") {$e = 0;}
(Need eq to test for this.  Single = is assigning operator.  Added
semicolon to second part.  You need something like $arg = $ARGV[0]; in
the beginning of your script or just replace $arg with $ARGV[0].)

                 else {$e = 1}
Should be: else {$e = 1;}
(No terminating semicolon)

                 if ($e = 1) {
Should be: if ($e == 1) {
(need == or eq to test for numeric value.)

                         open (LOG, ">>/perl/pinglog.txt";
                         print `date`;
                         print $a;
                         }
                 else {}
                 }


Am I doing my ifs correctly? Thanks,
mark
got root?



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

Reply via email to