php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45883 Snmp functions fail via CLI
Submitted: 2008-08-21 16:22 UTC Modified: 2008-08-21 20:15 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: richrumble at gmail dot com Assigned:
Status: Not a bug Package: SNMP related
PHP Version: 5.2.6 OS: Windows
Private report: No CVE-ID: None
 [2008-08-21 16:22 UTC] richrumble at gmail dot com
Description:
------------
Technically phpinfo() can show you part of the problem

With SNMP enabled, running that script from the browser will show you snmp enabled, running the phpinfo script from cli shows it's not enabled, but every other function is!

Any simple snmp command will result in the following error:
Fatal error: Call to undefined function snmprealwalk() 
substitute snmprealwalk with any snmp function


Reproduce code:
---------------
<?php
phpinfo();
?>

or

<?php
$host = "localhost";
$community = "public";
$oid = ".1.3.6.1.2.1.2.2.1.2";
$arr = snmpwalk($host, $community, $oid);
print_r($arr);
?>

Expected result:
----------------
PhpInfo(cli) that matches phpinfo from browser

SNMP results from host.

Actual result:
--------------
SNMP Extension missing from phpinfo when called via command line interface

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-08-21 16:30 UTC] pajoye@php.net
which php.ini is used by your webserver and which is used by cli?

Do you get any error while running cli (cannot find dll xyz, etc)?

Have you installed the required files and data as described in the manual?
 [2008-08-21 17:28 UTC] richrumble at gmail dot com
I've tried specifying the php.ini via the -c argument
C:\php>php.exe -c c:\php\php.ini snmptest.php
I've copied the php.ini file to c:\windows\ 

SNMP is enabled when I call phpinfo via the browser, but does not show enabled when called via CLI. It's easy to reproduce on any windows system. There appear to be no additional steps to install php-snmp extension, uncomment in php.ini, and snmpwalk works via browser, but fails via cli.
-rich
 [2008-08-21 17:35 UTC] pajoye@php.net
It does not make sense. Double check that the php.ini is correctly loaded and that you use the right extension_dir.

php.exe -i > info.txt and then open info.txt in your editor.
 [2008-08-21 18:53 UTC] richrumble at gmail dot com
I got it working with a new download and install, I think a wamp php.ini file was being used, very strange nonetheless that it worked via the browser calling the php vs the cli... Thanks for your time.
 [2008-08-21 20:15 UTC] pajoye@php.net
Not a bug > bogus.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 02:01:28 2024 UTC