Curt Shaffer wrote:
> 
> From: John W. Krahn [mailto:[EMAIL PROTECTED] 
>> 
>> Curt Shaffer wrote:
>>>
>>>my $test = system `/usr/bin/snmpget -v1 10.1.11.18 -c secret
>>>.1.3.6.1.4.1.710.7.1.5.1.23.1.13.1|awk '{print $4}'`;
>> 
>> You are using back-quotes AND system() so if your external command displayed
>> the text:
>> 
>> 1234
>> 
>> then the back-quotes would return "1234\n" and system() would run the
>> program
>> "1234\n" and return the exit status of the program "1234\n".
>> 
>> It looks like you may want something like:
>> 
>> my $test = ( split ' ', `/usr/bin/snmpget -v1 10.1.11.18 -c secret
>> .1.3.6.1.4.1.710.7.1.5.1.23.1.13.1` )[ 3 ];
>> 
>> Or perhaps you need to use one of the SNMP modules at:
>> http://search.cpan.org/search?m=module&q=snmp&s=1&n=100
> 
> I got it by doing the following:
>
> my $sig=0;
> $sig = qx(/usr/bin/snmpget -v1 $host -c secret
> .1.3.6.1.4.1.710.7.1.5.1.23.1.13.1);
> my @test=$sig;

Why?

> my @test=split(/ /,$sig);

split(/ /,$sig) splits on a single space character so if the output has
multiple spaces or tabs separating the fields then this won't work correctly.


> $sig=$test[3];


John
-- 
use Perl;
program
fulfillment

-- 
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