HI everyone,
i am a php beginner trying to generate one script for taking system information. Line "zonecfg.." i added recently and when i run the script, the page is waiting ..
<?php
$zonename = array();
$index = 0;
$connection = ssh2_connect('172.16.101.80', 22, array('hostkey'=>'ssh-rsa'));
if (ssh2_auth_pubkey_file($connection, 'root',
'/var/www/html/ssh/id_rsa.pub',
'/var/www/html/ssh/id_rsa', 'secret')) {
//echo "Public Key Authentication Successful\n";
} else {
die('Public Key Authentication Failed');
}
if($output = ssh2_exec($connection, 'zoneadm list -cv ')) {
stream_set_blocking($output, true);
$result= stream_get_contents($output);
$resultArray = preg_split('/[\s]+/',ltrim($result));
$rows = array_chunk($resultArray,6);
$columns = array_shift($rows);
$data = array();
foreach ($rows as $row) {
$q = array_combine($columns, $row);
if($q['NAME']=="global"){
if($globalNameStream = ssh2_exec($connection, 'hostname')){
stream_set_blocking($globalNameStream,true);
$q['NAME'] = stream_get_contents($globalNameStream);
}
}else{
echo $data[$index]['NAME'];
echo "<br/>";
$index++;
if($IpNameStream = ssh2_exec($connection,"zonecfg -z". $data[$index]['NAME'] ." info | grep address | awk '{print $2}'")){
stream_set_blocking($IpNameStream,true);
$q['IP'] = stream_get_contents($IpNameStream);
}}
$data[] = $q;
}
print_r($data);
echo "<br/>";
}
?>
on this above code, $data[index]['NAME'] is not accepting and the page hangs always. ig i gave the value insted of this variable, it;s giving output
please anyone help me to fic this
Regards,
Ben