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
try this syntax:
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}');
or
my $test = qx(you command above w/no quotes needed);
or
open (SNMP, snmpget -v1 10.1.11.18 -c secret
.1.3.6.1.4.1.710.7.1.5.1.23.1.13.1 ) or die failed
To: Curt Shaffer; Perl List
Subject: Re: odd variable result
try this syntax:
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}');
or
my $test = qx(you command above w/no quotes needed);
or
open (SNMP, snmpget -v1 10.1.11.18 -c
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
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