Connecting Tech Pros Worldwide Help | Site Map

Output shown only in Command line and not in browser

 
LinkBack Thread Tools Search this Thread
  #1  
Old June 29th, 2006, 06:05 AM
Manish
Guest
 
Posts: n/a
Default Output shown only in Command line and not in browser

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


  #2  
Old June 29th, 2006, 09:35 PM
Andy Hassall
Guest
 
Posts: n/a
Default Re: Output shown only in Command line and not in browser

On 28 Jun 2006 23:04:20 -0700, "Manish" <yehaimanish@gmail.com> wrote:
[color=blue]
>Why the variables are only displayed when executed from command line
>only and not from browser.[/color]

Most likely, differences in user permissions and environment variables between
your commandline and the webserver environment.

--
Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.