#19135 [Opn->Bgs]: Can't execute snmp functions

From: Date: Thu, 29 Aug 2002 15:47:58 +0000
Subject: #19135 [Opn->Bgs]: Can't execute snmp functions
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-18167@lists.php.net to get a copy of this message
ID: 19135 Updated by: sniper@php.net Reported By: george.travan@adelaide.edu.au -Status: Open +Status: Bogus Bug Type: SNMP related Operating System: solaris 2.6 PHP Version: 4.2.2 New Comment: Like I said in my previous comment, file() preserves any line ending characters in the array data.. Change the line to this: $status = snmpget(trim($workstation[$i]), $community, ".1.3.6.1.4.1.11.2.3.9.1.1.3.0", $timeout, $retries); And it works. This is not any bug.. Previous Comments: ------------------------------------------------------------------------ [2002-08-29 00:55:39] george.travan@adelaide.edu.au Sorry about the lack of detail :{ <?php $timeout= '300'; $retries= '10'; $community = "public"; $workstation = file("workstation.txt"); $num_workstation = count($workstation); for ( $i = 0 ; $i < $num_workstation; $i++) { print "Workstation: $workstation[$i] Community: $community Timeout: $timeout Retries: $retries"; //$sysname = snmpget( "localhost","public","system.sysName.0"); $status = snmpget($workstation[$i], $community, ".1.3.6.1.4.1.11.2.3.9.1.1.3.0", $timeout, $retries); echo $status; } ?> workstation.txt is a plain file with workstation addresses, ie dominator.adelaide.edu.au my-pc-room3.adelaide.edu.au Regards. ------------------------------------------------------------------------ [2002-08-28 22:42:45] kalowsky@php.net okay again, I ask for a simple sample script to reproduce this. Mainly because the sample you gave me, assumes $community exists, and that the array you're creating ($workstations) is correct. Sorry but more detail is needed. ------------------------------------------------------------------------ [2002-08-28 21:52:54] george.travan@adelaide.edu.au The $workstations array does report correctly the ip's on closer inspection. echo "-{$workstations[$i]-"; correctly identifies the array members. just seems to fail as an argument to snmpget. ------------------------------------------------------------------------ [2002-08-28 21:28:42] sniper@php.net Seems more like some bug in your script.. Are you sure $workstations[$i] holds the IP ? Try adding this before the snmpget() call: echo "-{$workstations[$i]-"; so you'll see that there aren't any extra stuff in it..like \n or so. Each line in that array returned by file will hold the line ending.. ------------------------------------------------------------------------ [2002-08-28 20:06:45] george.travan@adelaide.edu.au forgot to include that $number_of_workstations = count($workstations); seems to be a problem with $workstations[$i] in the loop causing this. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/19135 -- Edit this bug report at http://bugs.php.net/?id=19135&edit=1

« previous php.bugs (#18167) next »