Re: PHP [win32] & CLI Testers needed.



d43m0n AT shaw DOT ca wrote:
Hello,

I have found some code, and have included it into some source I have
written, lets just say to create shell emulation for now, and have
future plans to release it with multiple packages of future software to
make use of CLI for differnt environments.

My previous attempts to create the source below, ended with the loop
stopping due to undefined varible, that requested for user input, the
new source allows for the loop to process even if the varible and
reasource is "undefined" or "NULL". The purpose of course is to
maintain reasource, log, and to not exhaust any buffers waiting for
user input. The purpose for this also is to make a script automated for
its purposes and functions even w/o user input.

Potential purose includes client shells, server shells with shared
memory (unix/linux) for access to exsisting daemon's to acess logs,
objects and variables, AI, and replacment for terminal shell on
exsisting systems.

What I need is someone with Windows to execute the code below, and
report the results, wether or not it is truely possible for win32
environments to process such loop.

<?php
set_time_limit('0');

if (version_compare(phpversion(), '5.0.0', '<')) {
define('STDIN', fopen('php://stdin', 'r'));
}

$tmp = array();
$loop = 0;
echo 'root@localhost:~ # ';
while(true) {
sleep(1);
echo $loop++ . "\n";
unset($tmp['stream']);
$tmp['stream']['read'][] = STDIN;
stream_select($tmp['stream']['read'], $tmp['stream']['write'] =
NULL, $tmp['stream']['except'] = NULL, $tmp['stream']['tv'] = 0);
if (count($tmp['stream']['read'])) {
$tmp['stream']['buffer'] = @fread(STDIN, 1500);
$tmp['stream']['buffer'] = str_replace(array("\r", "\n"), "",
$tmp['stream']['buffer']);
echo $tmp['stream']['buffer'] . "\n";
echo 'root@localhost:~ # ';
}
unset($tmp['stream']);
}
print $template->foot();
?>

You will notice a su-linux like prompt, and you should notice a message
displayed as "Current loop: " that suggests the numeric rotation and
how many times the loop has ran through, and notice that simply typing
does not interupt the flow, that us until you press the return key.
However, as proclaimed, the sudden user input should interupt the loop,
that is for within Windows, and not for Linux.

Any and all responces to this post is appreciated. And hopfully we can
finally resolve any issues due to this problem in PHP compatibility.

Everyone is welcome to use this source code for their own projects and
will.

I have pretested this source code using the following:

[PHP]
PHP 4.4.0 (cli) (built: Sep 1 2006 15:09:18)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies

[Linux]
Linux term01 2.6.13-15.11-default #1 Mon Jul 17 09:43:01 UTC 2006
x86_64 x86_64 x86_64 GNU/Linux

* Daemon
---------------------------
/* No Comment */


>

I am running PHP 5.1.4 on Windoze XP SP 2. I am running this script from Eclipse with the .0.2.3 PHP IDE plugin for Eclipse. These are not all of the messages. I cut down because of the size because of being in a loop.

These are the messages I get during your loop (testforLinuxUser.php) on the console:

Notice: testforLinuxUser.php line 22 - Use of undefined constant STDIN - assumed 'STDIN'
Debug Strict (PHP 5): testforLinuxUser.php line 24 - Only variables should be passed by reference
Debug Strict (PHP 5): testforLinuxUser.php line 24 - Only variables should be passed by reference
Debug Warning: testforLinuxUser.php line 24 - stream_select(): supplied argument is not a valid stream resource
Debug Warning: testforLinuxUser.php line 24 - stream_select(): supplied argument is not a valid stream resource
Debug Warning: testforLinuxUser.php line 24 - stream_select() [<a href='function.stream-select'>function.stream-select</a>]: unable to select [0]: No error (max_fd=0)
Notice: testforLinuxUser.php line 26 - Use of undefined constant STDIN - assumed 'STDIN'
Debug Warning: testforLinuxUser.php line 26 - fread(): supplied argument is not a valid stream resource



I get the following on the Browser output during the loop:

X-Powered-By: PHP/5.1.4 Content-type: text/html root@localhost:~ # 0
Warning: stream_select(): supplied argument is not a valid stream resource in C:\Documents and Settings\Ed Taylor\My Documents\Projects Eclipse\workspaces\workspace PHP\Scrapboard\testforLinuxUser.php on line 24

Warning: stream_select(): supplied argument is not a valid stream resource in C:\Documents and Settings\Ed Taylor\My Documents\Projects Eclipse\workspaces\workspace PHP\Scrapboard\testforLinuxUser.php on line 24

Warning: stream_select() [function.stream-select]: unable to select [0]: No error (max_fd=0) in C:\Documents and Settings\Ed Taylor\My Documents\Projects Eclipse\workspaces\workspace PHP\Scrapboard\testforLinuxUser.php on line 24
root@localhost:~ # 1
Warning: stream_select(): supplied argument is not a valid stream resource in C:\Documents and Settings\Ed Taylor\My Documents\Projects Eclipse\workspaces\workspace PHP\Scrapboard\testforLinuxUser.php on line 24

Warning: stream_select(): supplied argument is not a valid stream resource in C:\Documents and Settings\Ed Taylor\My Documents\Projects Eclipse\workspaces\workspace PHP\Scrapboard\testforLinuxUser.php on line 24

Warning: stream_select() [function.stream-select]: unable to select [0]: No error (max_fd=0) in C:\Documents and Settings\Ed Taylor\My Documents\Projects Eclipse\workspaces\workspace PHP\Scrapboard\testforLinuxUser.php on line 24
root@localhost:~ # 2
Warning: stream_select(): supplied argument is not a valid stream resource in C:\Documents and Settings\Ed Taylor\My Documents\Projects Eclipse\workspaces\workspace PHP\Scrapboard\testforLinuxUser.php on line 24

Warning: stream_select(): supplied argument is not a valid stream resource in C:\Documents and Settings\Ed Taylor\My Documents\Projects Eclipse\workspaces\workspace PHP\Scrapboard\testforLinuxUser.php on line 24

Warning: stream_select() [function.stream-select]: unable to select [0]: No error (max_fd=0) in C:\Documents and Settings\Ed Taylor\My Documents\Projects Eclipse\workspaces\workspace PHP\Scrapboard\testforLinuxUser.php on line 24
root@localhost:~ # 3
Warning: stream_select(): supplied argument is not a valid stream resource in C:\Documents and Settings\Ed Taylor\My Documents\Projects Eclipse\workspaces\workspace PHP\Scrapboard\testforLinuxUser.php on line 24

Warning: stream_select(): supplied argument is not a valid stream resource in C:\Documents and Settings\Ed Taylor\My Documents\Projects Eclipse\workspaces\workspace PHP\Scrapboard\testforLinuxUser.php on line 24

Warning: stream_select() [function.stream-select]: unable to select [0]: No error (max_fd=0) in C:\Documents and Settings\Ed Taylor\My Documents\Projects Eclipse\workspaces\workspace PHP\Scrapboard\testforLinuxUser.php on line 24
root@localhost:~ # 4
Warning: stream_select(): supplied argument is not a valid stream resource in C:\Documents and Settings\Ed Taylor\My Documents\Projects Eclipse\workspaces\workspace PHP\Scrapboard\testforLinuxUser.php on line 24

Warning: stream_select(): supplied argument is not a valid stream resource in C:\Documents and Settings\Ed Taylor\My Documents\Projects Eclipse\workspaces\workspace PHP\Scrapboard\testforLinuxUser.php on line 24

Warning: stream_select() [function.stream-select]: unable to select [0]: No error (max_fd=0) in C:\Documents and Settings\Ed Taylor\My Documents\Projects Eclipse\workspaces\workspace PHP\Scrapboard\testforLinuxUser.php on line 24
root@localhost:~ # 5
Warning: stream_select(): supplied argument is not a valid stream resource in C:\Documents and Settings\Ed Taylor\My Documents\Projects Eclipse\workspaces\workspace PHP\Scrapboard\testforLinuxUser.php on line 24

Warning: stream_select(): supplied argument is not a valid stream resource in C:\Documents and Settings\Ed Taylor\My Documents\Projects Eclipse\workspaces\workspace PHP\Scrapboard\testforLinuxUser.php on line 24

Warning: stream_select() [function.stream-select]: unable to select [0]: No error (max_fd=0) in C:\Documents and Settings\Ed Taylor\My Documents\Projects Eclipse\workspaces\workspace PHP\Scrapboard\testforLinuxUser.php on line 24
root@localhost:~ # 6
Warning: stream_select(): supplied argument is not a valid stream resource in C:\Documents and Settings\Ed Taylor\My Documents\Projects Eclipse\workspaces\workspace PHP\Scrapboard\testforLinuxUser.php on line 24

Warning: stream_select(): supplied argument is not a valid stream resource in C:\Documents and Settings\Ed Taylor\My Documents\Projects Eclipse\workspaces\workspace PHP\Scrapboard\testforLinuxUser.php on line 24

Warning: stream_select() [function.stream-select]: unable to select [0]: No error (max_fd=0) in C:\Documents and Settings\Ed Taylor\My Documents\Projects Eclipse\workspaces\workspace PHP\Scrapboard\testforLinuxUser.php on line 24
root@localhost:~ # 7
Warning: stream_select(): supplied argument is not a valid stream resource in C:\Documents and Settings\Ed Taylor\My Documents\Projects Eclipse\workspaces\workspace PHP\Scrapboard\testforLinuxUser.php on line 24

Warning: stream_select(): supplied argument is not a valid stream resource in C:\Documents and Settings\Ed Taylor\My Documents\Projects Eclipse\workspaces\workspace PHP\Scrapboard\testforLinuxUser.php on line 24

Warning: stream_select() [function.stream-select]: unable to select [0]: No error (max_fd=0) in C:\Documents and Settings\Ed Taylor\My Documents\Projects Eclipse\workspaces\workspace PHP\Scrapboard\testforLinuxUser.php on line 24
root@localhost:~ # 8
Warning: stream_select(): supplied argument is not a valid stream resource in C:\Documents and Settings\Ed Taylor\My Documents\Projects Eclipse\workspaces\workspace PHP\Scrapboard\testforLinuxUser.php on line 24

Warning: stream_select(): supplied argument is not a valid stream resource in C:\Documents and Settings\Ed Taylor\My Documents\Projects Eclipse\workspaces\workspace PHP\Scrapboard\testforLinuxUser.php on line 24

Warning: stream_select() [function.stream-select]: unable to select [0]: No error (max_fd=0) in C:\Documents and Settings\Ed Taylor\My Documents\Projects Eclipse\workspaces\workspace PHP\Scrapboard\testforLinuxUser.php on line 24
root@localhost:~ # 9
Warning: stream_select(): supplied argument is not a valid stream resource in C:\Documents and Settings\Ed Taylor\My Documents\Projects Eclipse\workspaces\workspace PHP\Scrapboard\testforLinuxUser.php on line 24

Warning: stream_select(): supplied argument is not a valid stream resource in C:\Documents and Settings\Ed Taylor\My Documents\Projects Eclipse\workspaces\workspace PHP\Scrapboard\testforLinuxUser.php on line 24

Warning: stream_select() [function.stream-select]: unable to select [0]: No error (max_fd=0) in C:\Documents and Settings\Ed Taylor\My Documents\Projects Eclipse\workspaces\workspace PHP\Scrapboard\testforLinuxUser.php on line 24
root@localhost:~ # 10
Warning: stream_select(): supplied argument is not a valid stream resource in C:\Documents and Settings\Ed Taylor\My Documents\Projects Eclipse\workspaces\workspace PHP\Scrapboard\testforLinuxUser.php on line 24

Warning: stream_select(): supplied argument is not a valid stream resource in C:\Documents and Settings\Ed Taylor\My Documents\Projects Eclipse\workspaces\workspace PHP\Scrapboard\testforLinuxUser.php on line 24

Warning: stream_select() [function.stream-select]: unable to select [0]: No error (max_fd=0) in C:\Documents and Settings\Ed Taylor\My Documents\Projects Eclipse\workspaces\workspace PHP\Scrapboard\testforLinuxUser.php on line 24


--
Thanks in Advance...
IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
.



Relevant Pages

  • Re: PHP [win32] & CLI Testers needed.
    ... written, lets just say to create shell emulation for now, and have ... My previous attempts to create the source below, ended with the loop ... Debug Warning: testforLinuxUser.php line 24 - stream_select: supplied argument is not a valid stream resource ...
    (php.general)
  • Re: Undefined Index
    ... Warning: fwrite: supplied argument is not a valid stream resource in ... Get parameters in form action work only if the form method is POST... ...
    (comp.lang.php)
  • Re: fopen php5 htaccess question
    ... Warning: fwrite: supplied argument is not a valid stream resource in ... > Class CreateXML{ ... > public function xmlDeclaration(){ ...
    (comp.lang.php)
  • Re: Problem with fsockopen()
    ... Temporary failure in name resolution in ... Warning: fwrite: supplied argument is not a valid stream resource in ...
    (comp.lang.php)
  • Re: 2.6.16-rc1-mm4
    ... >>> WARNING: Loop detected: ... >>> WARNING: Module ... That kgdb stub is slowly deteriorating as everyone hacks on everything else. ... To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ ...
    (Linux-Kernel)