Please help - exact same code does not work on another PC

I have 5 windows 10 computers. All of them are using XAMPP for Windows 7.3.1

I have the following code

<?php

// get vlan list from the switch

$ip = "xx.xx.xx.xx";
     

$runCommand = "c:\\snmpwalk   -On -v 1  -c password "    .$ip.       " SNMPv2-SMI::enterprises.6486.800.1.2.1.3.1.1.1.1.1.2";


$WshShell = new COM("WScript.Shell");

$output  = shell_exec("$runCommand");
$classes = explode("\n",$output);

foreach ($classes as $val) {

echo nl2br("$val\r");

echo $val;


}


?> 

The above code works perferctly on one computer.

Yet the very same code does not work on another 4 computers and no data is displayed when the php code is run. All the computers are the same build and run the same OS Windows 10. No errors are generated when the code is run.

Can anyone help me please?>

Try changing shell_exec for passthru,

At least you’ll get some idea of what’s happening.

Well, let’s walk you thru this… First, “snmpwalk” is an app you need to install on EACH of the computers. Since it runs “locally” on each system, this app must be installed on each computer running it.
Next, it must be installed in the same place on each computer at the same location for the same command string to work as-is. Since this is a PHP script calling the app, the PHP script must be executed on the same computer as the snmpwalk is installed. So, the PHP code must be on each computer, too.
Hope that helps…

Sponsor our Newsletter | Privacy Policy | Terms of Service