alon.0101 Posted June 30, 2008 Share Posted June 30, 2008 Hi there, I'm trying to change a port-state on a switch on/off and using the following code: $ip = '10.0.0.1'; $oid = '.1.3.6.1.2.1.2.2.1.7.10'; $result = snmpset($ip,"RWaccess",$oid,"i","1",1000000,0); echo $result; this code works great, and the $result is "1". but if the command fails (invalid ip or community for example), it won't return FALSE just displays the error: Warning: snmpset() [function.snmpset]: No response from 10.0.0.1 in C:\wamp\www\test.php on line 9 How do i check if the command fails? i don't want that error msg... Thanks in advance! Alan. Link to comment https://forums.phpfreaks.com/topic/112542-snmpset-return-values-problem/ Share on other sites More sharing options...
MasterACE14 Posted June 30, 2008 Share Posted June 30, 2008 you could do something like... <?php if($result != 1) { die("No Response: here is my custom error!"); } ACE Link to comment https://forums.phpfreaks.com/topic/112542-snmpset-return-values-problem/#findComment-577924 Share on other sites More sharing options...
alon.0101 Posted June 30, 2008 Author Share Posted June 30, 2008 Hi Ace, thanks for your quick answer! I tried to add die() and Or die() and i still get the warning message plus the error one... $result = (snmpset($ip,"RWaccess",$oid,"i","1",1000000,0) or die("No Response: here is my custom error!")); if($result != 1) { die("No Response: here is my custom error!"); } Maybe i'm doing something wrong.. Link to comment https://forums.phpfreaks.com/topic/112542-snmpset-return-values-problem/#findComment-577932 Share on other sites More sharing options...
MasterACE14 Posted June 30, 2008 Share Posted June 30, 2008 hmmm, interesting. I've never worked with this port stuff before. But that should of worked :-\ try this: <?php $result = (snmpset($ip,"RWaccess",$oid,"i","1",1000000,0) or die("No Response: here is my custom error!")); if($result == FALSE) { die("No Response: here is my custom error!"); } let me know what you get. Link to comment https://forums.phpfreaks.com/topic/112542-snmpset-return-values-problem/#findComment-577935 Share on other sites More sharing options...
alon.0101 Posted June 30, 2008 Author Share Posted June 30, 2008 Hey again I still get the warning message after changing return value from != 1 to == FALSE. Link to comment https://forums.phpfreaks.com/topic/112542-snmpset-return-values-problem/#findComment-577953 Share on other sites More sharing options...
MasterACE14 Posted June 30, 2008 Share Posted June 30, 2008 try it without the outer parenthesis: <?php $result = snmpset($ip,"RWaccess",$oid,"i","1",1000000,0); if($result == FALSE) { die("No Response: here is my custom error!"); } Link to comment https://forums.phpfreaks.com/topic/112542-snmpset-return-values-problem/#findComment-577974 Share on other sites More sharing options...
alon.0101 Posted June 30, 2008 Author Share Posted June 30, 2008 Hi Ace, Still doesn't work, i get this warning message everytime the function fail. Link to comment https://forums.phpfreaks.com/topic/112542-snmpset-return-values-problem/#findComment-577993 Share on other sites More sharing options...
MasterACE14 Posted June 30, 2008 Share Posted June 30, 2008 hmmm ok. Back to the drawing board. Link to comment https://forums.phpfreaks.com/topic/112542-snmpset-return-values-problem/#findComment-577997 Share on other sites More sharing options...
alon.0101 Posted July 1, 2008 Author Share Posted July 1, 2008 Anyone else maybe have an idea? I can't get other results from snmpget/set Link to comment https://forums.phpfreaks.com/topic/112542-snmpset-return-values-problem/#findComment-578864 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.