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.2.0RC4 on Windoze XP SP 2. I am running this script from Eclipse with the .0.2.3 PHP IDE plugin for Eclipse.

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

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


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

  • 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 ... stopping due to undefined varible, that requested for user input, the ... finally resolve any issues due to this problem in PHP compatibility. ...
    (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)
  • 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: Efficiency questions: combined ifs and looping 4 times
    ... Choice of algorithm always has a far bigger impact in performance than ... Use sizeof before the loop, store the result in a var and use ... speaks well of PHP. ... your order of complexity analysis is off. ...
    (comp.lang.php)
  • 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)