Re: PHP [win32] & CLI Testers needed.
- From: "d43m0n AT shaw DOT ca" <barryd.it@xxxxxxxxx>
- Date: 20 Sep 2006 09:05:59 -0700
IchBin wrote:
IchBin wrote:
d43m0n AT shaw DOT ca wrote:If I knew that you multi posted to different groups independently of
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
each other I would have not wasted my time.
--
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-)
The purpose of the script will not to be run in the browser, there is
no purpose to even preprocess it under http. However, to insure its use
under cli, I will define a cli if statment, and the contstant is a
weird error, but thankyou for bringing it to my attention, i'll besure
to check it out myself.
I have already started developing packages for the source code in a
project called phpMini, which is a personal emulator, capable of
detecting when a package dies, and to start a new package, apon request.
.
- References:
- PHP [win32] & CLI Testers needed.
- From: d43m0n AT shaw DOT ca
- Re: PHP [win32] & CLI Testers needed.
- From: IchBin
- Re: PHP [win32] & CLI Testers needed.
- From: IchBin
- PHP [win32] & CLI Testers needed.
- Prev by Date: Most stable combination of AMP?
- Next by Date: Re: [PHP] Re: Most stable combination of AMP?
- Previous by thread: Re: PHP [win32] & CLI Testers needed.
- Next by thread: I'm getting a wierd error while loading APC
- Index(es):
Relevant Pages
|