Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Child Process Issues

Status
Not open for further replies.

BumpBump

Technical User
Sep 9, 2004
5
US
This is part of a larger script. I am having issues with running the child process and splitting the results.

Here is a script that works:
# Set the snmp community string password.
$Comstr = "communitystring";
# Set the server name to query.
$server = "servername";
#Change to the directory the program is in:
chdir "/usr/bin" or die "Cannot chdir /usr/bin: $!";

print "$server\n";
# the $variable doesn't seem to be set.
$variable = system "snmpgetnext", "-v1", "-c", $Comstr, "-O", "Qv", $server, "system.sysUpTime";
#take the variable from above and do a split.
@fields = split /:/,$variable;

## @fields prints a Zero
print "@fields\n";
## $vairiable prints a Zero
print "$variable\n";

#this is what i want the output to look like!!!
@fields2 = split /:/,"13:13:56:52.50";
print "@fields2\n";


Now I've started another script doing the same thing with the Net::SNMP but if the script hits a server that doesn't respond it stops.

thanks for any help.
 
Code:
$variable = `snmpgetnext -v1 -c $Comstr -O Qv $server system.sysUpTime`;

system only returns the exit code of the program when it exits; not the results the program prints to the screen.

Use `` to call it and it'll return the output.

-------------
Cuvou.com | The NEW Kirsle.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top