You are here: Output shown only in Command line and not in browser « All PHP « IT news, forums, messages
Output shown only in Command line and not in browser

Posted by Manish on 10/10/32 11:51

I have the following code in a script
--------------------------------------------------------------------------------------------------------------------------------
foreach($serverlist as $sno=>$serverdata) {
$servername = $serverdata['name'];
if($servername) {

unset($outputstr, $outputarr);
$outputstr = exec("ssh -n ".$servername." 'fstat | wc
-l'",
$outputarr);

echo
"\r\n----------------------------------------------------------";
echo "\r\nssh -n ".$servername." 'fstat | wc -l' ";
echo "\r\nservername = ".$servername;
echo "\r\noutputstr = "; var_dump($outputstr);
echo "\r\noutputarr = "; var_dump($outputarr);

}
}

--------------------------------------------------------------------------------------------------------------------------------

When executed from browser it displayed:

---------------------------------------------------------- ssh -n
192.168.0.155 'fstat | wc -l' servername = 192.168.0.155 outputstr =
string(0) "" outputarr = array(0) { }
---------------------------------------------------------- ssh -n
192.168.0.156 'fstat | wc -l' servername = 192.168.0.156 outputstr =
string(0) "" outputarr = array(0) { }
---------------------------------------------------------- ssh -n
192.168.0.159 'fstat | wc -l' servername = 192.168.0.159 outputstr =
string(0) "" outputarr = array(0) { }

--------------------------------------------------------------------------------------------------------------------------------

When executed from command line it displayed:

PHP Warning: Module 'ctype' already loaded in Unknown on line 0
PHP Warning: Module 'SimpleXML' already loaded in Unknown on line 0
PHP Warning: Module 'dom' already loaded in Unknown on line 0
PHP Warning: Module 'iconv' already loaded in Unknown on line 0
PHP Warning: Module 'pspell' already loaded in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library
'/usr/local/lib/php/20041030-debug/ssh2.so' -
/usr/local/lib/php/20041030-debug/ssh2.so: unsupported file layout in
Unknown on line 0
PHP Warning: Module 'pcre' already loaded in Unknown on line 0
PHP Warning: Module 'xml' already loaded in Unknown on line 0
bash: fstat: command not found
Password:

----------------------------------------------------------
ssh -n 192.168.0.155 'fstat | wc -l'
servername = 192.168.0.155
outputstr = string(8) " 340"

outputarr = array(1) {
[0]=>
string(8) " 340"

}

----------------------------------------------------------
ssh -n 192.168.0.159 'fstat | wc -l'
servername = 192.168.0.159
outputstr = string(1) "0"

outputarr = array(1) {
[0]=>
string(1) "0"

}

----------------------------------------------------------
ssh -n 192.168.0.156 'fstat | wc -l'
servername = 192.168.0.156
outputstr = string(8) " 530"

outputarr = array(1) {
[0]=>
string(8) " 530"

}

--------------------------------------------------------------------------------------------------------------------------------

Why the variables are only displayed when executed from command line
only and not from browser.

I have tried using sleep() command after exec(), but no change.
$outputstr = exec("ssh -n ".$servername." 'fstat | wc -l'",
$outputarr);
sleep(2);

Thanks.
Manish

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация