Easiest way(I think) would be to change the bit of code that reads:
#Prompt for SNMP community string
print "community: ";
chomp($community = <STDIN>);
to
$community=WHATEVERYOURCOMMUNITYSTRINGIS;
Then launch the script with cdppoll.pl ip > nameoftextfile
I am sure that there is a better way to do this(and one day I'll get off my but and add some text output as an option)
Or if you open a filehandle to write to inside the code change the format STDOUT to format FILEHANDLE and the write to write FILEHANDLE. That should work as well.
| [reply] [d/l] |
Put stuff like the community string into a config file and load it as needed. I use Config::Tiny but there are a host of alternatives.
I put any variable that I may need in more than one program into a central system config file. That way, when community strings, passwords, file paths, etc. change, I only have to modify one file instead of twenty.
Hope this helps,
Jack
| [reply] |