I'm trying to call a php function, that run a shell command, inside my JavaScript on same page, it is supposed to return different value on each call but it call many times and use just the first return
PHP code:
<?php
$consulta = 'snmpget.exe -r:'.$ip.' -c:'.$dominio.' -o:'.$oid.'';
function exeSnmp ($consulta){
$arr = explode('Value=', shell_exec($consulta));
return preg_replace( "/\r|\n/", "", $arr[1] );
}
?>
And my JS code:
setInterval(function() {
var snmp = <?php echo json_encode(exeSnmp($consulta), JSON_HEX_TAG); ?>;
//doing something with snmp var
}, 1000);
When I run this code, I get always the same value from call exeSnmp() function, but its change on my system.
Thanks in advance.