You are here: [Test Needed] PHP [win32] & CLI required for testing. « All PHP « IT news, forums, messages
[Test Needed] PHP [win32] & CLI required for testing.

Posted by d43m0n AT shaw DOT ca on 09/28/95 11:58

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

 

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

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