#!/usr/bin/perl
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
# Descrs [file...]                                                            #
#                                                                             #
# This uses the SNMP "Next" command to query a list  of  machines  for  their #
# sysDescr  strings.  If file names are given on the command line, we'll read #
# the files and feed the contents (line at a time) to Next as its host  name. #
# You  can  also  include  args  like PORT=1234 in the file, and they will be #
# passed along to Next as you'd expect.                                       #
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
$, = ' ';
for $h (@ARGV) {
	if ($pid = fork) {
#		print "Parent $$\n";
	} elsif (defined $pid) {
#		print "Ping $h ...\n";
#		print "Next","+h",$h,"public","sysDescr","\n";
		exec  "Next","+h",$h,"public","sysDescr";
	} elsif ($! =~ /No more process/) {
		print "Fork failed; can't ping $h.\n";
		die "No more processes.\n";;
	} else {
		die "$0: Can't fork: $!\n";
	}
}
# Now sit around and wait for the children to exit, so
# our output doesn't get mixed up with the shell's prompts.
while (($pid = wait) > 0) {
	print "Process $pid exited.\n";
}
