Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Attempting move from shell to perl

Status
Not open for further replies.

sumncguy

IS-IT--Management
Joined
May 22, 2006
Messages
118
Location
US

I am trying to become more fluent with perl. I need another set of eyes to look at this. I want to check that the user enters a community string every time and either a single ip or a source file.

Am I missing anything ? Thanks apreeesch the help ...

script cut here
sub dosnmp {
print "cmd line ok eventually do snmp stuff\n";
exit;
}
#
sub err {
print STDERR <<EOF;

Syntax :
dsnmp -c <comm_string> <ip address>
or
dsnmp -c <comm_string> -f <filename>

EOF
exit;
}
#Handle Options
getopt ('fc');
if ($opt_f) {$ifil="$opt_f"};
if ($opt_c) {$rw="$opt_c"};
#
#check that user enters the mandatory RW string
#and a file or single ip.
if (!($rw)) { system ("tput clear"); err; }
#
if (!($ifil)) { $ip = shift; }
#
if (!($ip)) { system ("tput clear"); err; } else { dosnmp; }
#
script cut here
 
OK, but what does and what does not work..?!?

I mean, this looks kind of ok on first glance.
Though this:

Code:
if ($opt_f) {$ifil="$opt_f"};
if ($opt_c) {$rw="$opt_c"};
is redundant as far as I can see...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top