On Tuesday 04 April 2006 23:46, Mazhar wrote:
> Hi Guyz,

Hi Mazhar,

>             i am writin a script to automate the command snmpwalk by
> reading the contents of a file. Below is the snippet
>
> $file_name="somefile.txt";
>
> open(FILE,"< $file_name");
>
> while(<FILE>)
> {
>         my $ip;
>         my $comm_string;
>         ($ip,$comm_string)=split(",",$_);
>         $tempRNA=qw("snmpwalk -t 1 -r 1 $ip $comm_string .1.3.6.1.2.1.1.5 >
> RNA$ip.txt");
>

This might work for you

#!/usr/bin/perl
use strict;
use warnings;

my $file_name = "somefile.txt";

open(FILE, "< $file_name") or die("Error opening $file_name: $!\n");

while(<FILE>)
{
        chomp;
        my ($ip, $comm_string) = split ",";
        my $tempRNA = "snmpwalk -t 1 -r 1 $ip $comm_string .1.3.6.1.2.1.1.5 > 
RNA$ip.txt";
        
        print "$tempRNA\n";
}

Good luck

> *** I am facing the problem in the above code where in i have to pass all
> the information to the variable $tempRNA and then execute the same in the
> System ($tempRNA)
>
> When i try to print the value in the variable $tempRNA i am getting the
> value printed only RNAxx.xxx.xxx.xxxx.txt
>
> Please help me out and Thanks is Advance
>
> Regards
> Mazhar

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to