开发者

IOException on snmpwalk when run on JBoss server(JSP - servlet model)

When I run the code below in plain java project, everything works fine.

Process p = Runtime.getRuntime().exec(cmd);

--> where cmd = "snmpwalk -v 2c -c public 192.168.11.95 hrStorageAllocationUnits.1"

But when I place the code in a java servlet, this error is shown:

ERROR [STDERR] java.io.IOException: CreateProcess: snmpwalk -v 2c -c public 192.168.11.95 hrStorageAllocationUnits.1 error=2
ERROR [STDERR]  at 开发者_如何学JAVAjava.lang.ProcessImpl.create(Native Method)
ERROR [STDERR]  at java.lang.ProcessImpl.<init>(ProcessImpl.java:81)
ERROR [STDERR]  at java.lang.ProcessImpl.start(ProcessImpl.java:30)
ERROR [STDERR]  at java.lang.ProcessBuilder.start(ProcessBuilder.java:451)
ERROR [STDERR]  at java.lang.Runtime.exec(Runtime.java:591)
ERROR [STDERR]  at java.lang.Runtime.exec(Runtime.java:429)
ERROR [STDERR]  at java.lang.Runtime.exec(Runtime.java:326)


What does the servlet have for a PATH? Does it work in the servlet if you change cmd to "/usr/bin/snmpwalk -v 2c -c public 192.168.11.95 hrStorageAllocationUnits.1" (or something other than /usr/bin if you have snmpwalk installed somewhere else)?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜