I'm trying to create a PHP page that I can go to in order to get information from cisco switches we have. My only current option for reading data from them is to use rancid's clogin.
When I run:
sudo -u www-data /usr/lib/rancid/bin/clogin -f /home/www-data/.cloginrc -c 'show run int fa 0/1' as-switch-123 2>&1
it runs and returns the information about port 0/1.
However when I run the following:
<?php
ini_set('display_errors',1);
error_reporting(E_ALL);
$mainCommand = "/usr/lib/rancid/bin/clogin -f /home/www-data/.cloginrc -c 'show run int fa 0/1' as-switch-123 2>&1";
$outputArray = array();
echo exec($mainCommand,$outputArray,$returnCode);
echo '<br /><br />';
var_dump($outputArray);
echo '<br /><br />';
var_dump($returnCode);
?>
I get the return from $outputArray shown below:
array(5) {
[0]=> string(16) "no such variable"
[1]=> string(31) " (read trace on "env(HOME)")"
[2]=> string(23) " invoked from within"
[3]=> string(40) ""set password_file $env(HOME)/.cloginrc""
[4]=> string(47) " (file "/usr/lib/rancid/bin/clogin" line 66)"
}
Does anyone know why its not giving me the output the same as when you run it from sudo?