1

I'm creating an application at work that uses SNMPWalk to get details on specific IP addresses. Right now it's meant to use Nmap to find all printers in a specified network and then it uses SNMPWalk to get details on each printer.

The problem is that SNMPWalk is giving me the error:

"No log handling enabled - using stderr logging
-v2c:  (Sub-id not found: (top) -> -v2c)"

My code is here:

Process p = new Process();

p.StartInfo.FileName = snmploc + "\\snmpwalk.exe";

p.StartInfo.ErrorDialog = false;

p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = false;

p.StartInfo.WorkingDirectory = snmploc;

p.StartInfo.Arguments = "–mALL -v2c –cpublic " + printer.IP();

p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;

p.Start();

Console.WriteLine("Snmpwalk has been fired");

Console.WriteLine("Waiting for Snmp to terminate...");

string output = p.StandardOutput.ReadToEnd();

string error = p.StandardError.ReadToEnd();

p.WaitForExit();

Console.WriteLine(p.ExitCode);

printer is an object of the class Printer. It is used to contain printer details such as ip address, name, model, serial number, and open ports. snmploc is obtained from command line arguments.

The main reason that this is so complicated is that when I try using the exact same command in a command prompt it works perfectly.

  • I changed up the order of the arguments and capitalized the V. It now reads `"-V2c –cpublic -mAll " + printer.IP();` `output` is now "" and `error` is `"NET-SNMP version: 5.6.1.1\r\n"` `ExitCode` has a value of 0. I hope this helps people in finding a solution! – Jonathan Zinck Jul 01 '13 at 14:37
  • I found the solution! `p.StartInfo.Arguments = "-v2c -cpublic -mAll " + printer.IP();` is the way to go. Also, use the answer to this [question](http://stackoverflow.com/questions/5718473/c-sharp-processstartinfo-start-reading-output-but-with-a-timeout) to redirect the output. – Jonathan Zinck Jul 01 '13 at 16:16
  • You ought to write the answer as an answer, at least to prevent others from wasting time trying to solve it! – Ian Oct 13 '14 at 17:04

0 Answers0