List,

 

I am trying to set a variable based on a system call. Here is my code:

 

#!/usr/bin/perl

 

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}'`;

print "$test\n";

 

When I run that command from the command line it works as desired. When I
run the script with the system command in " rather than ` it returns the
whole value rather than the $4 that I need, then the print $test returns 0.
When I run the script as above the print $test it appears to set the
variable but produces a -1 which is not in the value that is returned at
all. Anyone have some guidance for me on how to do this properly?

 

Thanks

 

Curt

Reply via email to