PHP [win32] & CLI Testers needed.



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 */

.



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 ... finally resolve any issues due to this problem in PHP compatibility. ... Debug Warning: testforLinuxUser.php line 24 - stream_select: supplied argument is not a valid stream resource ...
    (php.general)
  • [Test Needed] PHP [win32] & CLI required for testing.
    ... written, lets just say to create shell emulation for now, and have ... My previous attempts to create the source below, ended with the loop ... stopping due to undefined varible, that requested for user input, the ... finally resolve any issues due to this problem in PHP compatibility. ...
    (alt.php)
  • Execute extneral programs with interactivity?
    ... (I don't need my script to send input to the command). ... None of the PHP program-execution commands seem to work for me. ... which takes user input, but it seems to buffer the output until you ... exactly as it does from a shell. ...
    (comp.lang.php)
  • Re: Unix-ify File Names
    ... special characters do make it more difficult to handle arbitrary file ... At least in POSIX shell. ... it's old value inside of the loop. ...
    (Debian-User)
  • Re: set environment Path variable
    ... home directory it is missing. ... indicates that the php command can't be found. ... php under the directory in which you installed the php package. ... When the shell ...
    (comp.unix.shell)