Curt Shaffer wrote:
> List,

Hello,

> I am trying to set a variable based on a system call.

In Perl a "system call" would be open() or link() or crypt(), etc.  You mean
that you are trying to set a variable based on the output of an external 
program.


> Here is my code:
> 
> #!/usr/bin/perl

use warnings;

> use strict;
> 
> 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



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