Sponsored Content
Full Discussion: Perl Loop Problem
Special Forums UNIX and Linux Applications Infrastructure Monitoring Perl Loop Problem Post 302417680 by mrlayance on Friday 30th of April 2010 09:07:58 AM
Old 04-30-2010
Perl Loop Problem

Another newbie question... I can not figure out how to get this running using a loop. Here is what I have now.

Code:
#!/usr/bin/perl
use SNMP::Info;                     
$list="list.list";
open(DAT, $list) || die("Can't Open List");
@raw_data=<DAT>;
close(DAT);
foreach $dest (@raw_data)
{
chomp($dest);
 my $ciscostats = new SNMP::Info(
                    AutoSpecify => 1,
                    Debug       => 1,
                    # These arguments are passed directly on to SNMP::Session
                    DestHost    => '$dest',
                    Community   => 'com',
                    Version     => 2
)
 
 my $serial = $ciscostats->serial();
 my $description = $ciscostats->description();
 
print "$dest - $description\n";
print "$serial\n";
}

This is the error I am stuck on.

Code:
syntax error at ios1.pl line 23, near ")
 my "
Execution of ios1.pl aborted due to compilation errors.

Thanks in advance.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

help with perl while loop

Can anyone tell me why this program won't kick out when the time gets beyond time in the loop? sub showtime { local($format,$military)=@_; ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time); if ((! $military) &amp;&amp; ($hour &gt; 12)) {$hour-=12;} ... (2 Replies)
Discussion started by: methos
2 Replies

2. Shell Programming and Scripting

for loop in perl

my $i; my $j; for($i=1;$i<=5;$i++) { for($j=$i;$j<5;$j++) { print " "; } print "$i\n"; } But the output i need is 1 12 123 1234 12345 Help me please (5 Replies)
Discussion started by: priyas
5 Replies

3. Shell Programming and Scripting

Perl - pass shell-vars into perl for input loop

I need to process a file line-by-line using some value from a shell variable Something like:perl -p -e 's/$shell_srch/$shell_replace/g' input.txt I can't make the '-s' work in the '-p' or '-n' input loop (or couldn't find a syntaxis.) I have searched and found... (4 Replies)
Discussion started by: alex_5161
4 Replies

4. Shell Programming and Scripting

until loop Perl

I am trying to print out a section of a file begining at the start and printng until a character is found. My code and input file are below. This code is printing out every line except for the line with the character which is not what I want the out put should be a file with numbers 1-4. ... (3 Replies)
Discussion started by: cold_Que
3 Replies

5. Shell Programming and Scripting

Help with PERL loop

I wrote a script to list all lines in a file with Perl. I am having trouble with the looping part of it. My script is supposed to look at the file and as long as the file is larger than the current line it prints a new line. I am getting an error that won't stop on the while line of my code I... (4 Replies)
Discussion started by: zero3ree
4 Replies

6. Programming

while loop perl

I am trying to create a success and fail as below in a perl script : while echo$? is 2 it should append as below to .fail file ===================== if ( open(IN, "$outputfile")) { while( $my_line = <IN> ) { #print "$my_line \n" ; return 0; ... (3 Replies)
Discussion started by: sriram003
3 Replies

7. Shell Programming and Scripting

While Loop in Perl

Hi All I am reading the file using while loop in Perl someting like while (my $s=<F>){ chomp($s); .. .. .. } What i want to do is after the chomp statement i used some condition, if the condition is met then it should move forward otherwise it should read the new line. How Can it be... (4 Replies)
Discussion started by: parthmittal2007
4 Replies

8. Shell Programming and Scripting

perl while loop for each

I have the below scenario in perl cd $FIDE_RECEIVE ; # see the files that start with feedmgr.usfed.tips $CycleDate = &fi_get_curr_date('US','NIGHTLY_CYCLE','PROCESS'); head -1 GNM_GEO.DAT.EMBS* |grep -v GNM_GEO.DAT.EMBS | awk '{$4 " " $5}' output for above command :... (3 Replies)
Discussion started by: ptappeta
3 Replies

9. Shell Programming and Scripting

Perl: Problem in retaining values after each loop

use strict; use warnings; open (my $fhConditions, "<input1.txt"); #open input file1 open (my $fhConditions1, "<input2.txt");#open input file2 open (my $w1, ">output1"); open (my $w2, ">output2"); our $l = 10;#set a length to be searched for match our $site="AAGCTT";#pattern to be matched... (1 Reply)
Discussion started by: anurupa777
1 Replies

10. Shell Programming and Scripting

PERL script loop problem

I have written the below PERL script to reprocess messages from a failure queue. It basically browses all the messages in the failure queue to individual files in a directory and then scans those files to determine the originating queue. The script will then move each message in turn from the... (0 Replies)
Discussion started by: chris01010
0 Replies
Info::Layer3::Netscreen(3pm)				User Contributed Perl Documentation			      Info::Layer3::Netscreen(3pm)

NAME
SNMP::Info::Layer3::Netscreen - SNMP Interface to Juniper Netscreen Devices AUTHOR
Kent Hamilton SYNOPSIS
#Let SNMP::Info determine the correct subclass for you. my $netscreen = new SNMP::Info( AutoSpecify => 1, Debug => 1, DestHost => 'myswitch', Community => 'public', Version => 2 ) or die "Can't connect to DestHost. "; my $class = $netscreen->class(); print "SNMP::Info determined this device to fall under subclass : $class "; DESCRIPTION
Provides abstraction to the configuration information obtainable from a Netscreen device through SNMP. See inherited classes' documentation for inherited methods. my $netscreen = new SNMP::Info::Layer3::Netscreen(...); Inherited Classes SNMP::Info::Layer3 Required MIBs NETSCREEN-SMI NETSCREEN-PRODUCTS-MIB NETSCREEN-INTERFACE-MIB NETSCREEN-SET-GEN-MIB Inherited Classes See "Required MIBs" in SNMP::Info::Layer3 and its inherited classes. GLOBALS
These are methods that return scalar value from SNMP $netscreen->vendor() Returns 'netscreen' $netscreen->os() Returns 'screenos' $netscreen->os_ver() Extracts the OS version from the description string. $netscreen->serial() Returns serial number.. Overrides $netscreen->layers() Returns 01001100. Device doesn't report layers properly, modified to reflect Layer3 functionality. Globals imported from SNMP::Info::Layer3 See "GLOBALS" in SNMP::Info::Layer3 for details. TABLE METHODS
These are methods that return tables of information in the form of a reference to a hash. Table Methods imported from SNMP::Info::Layer3 See "TABLE METHODS" in SNMP::Info::Layer3 for details. perl v5.12.4 2011-09-28 Info::Layer3::Netscreen(3pm)
All times are GMT -4. The time now is 08:07 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy