File: ssh2_stream_select.phpt

package info (click to toggle)
php-ssh2 1.3.1%2B0.13-7
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 472 kB
  • sloc: ansic: 5,963; xml: 477; pascal: 38; makefile: 1
file content (36 lines) | stat: -rw-r--r-- 725 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
--TEST--
ssh2_stream_select() - Tests opening a shell and using stream_select
--SKIPIF--
<?php require('ssh2_skip.inc'); ssh2t_needs_auth(); ?>
--FILE--
<?php require('ssh2_test.inc');

$ssh = ssh2_connect(TEST_SSH2_HOSTNAME, TEST_SSH2_PORT);
var_dump(ssh2t_auth($ssh));
$shell = ssh2_shell($ssh);
var_dump($shell);

fwrite($shell, "echo \"howdy\"\n");
sleep(1);

$read = [$shell];
$write = null;
$except = null;
$timeout = 5;
$start = time();
if (stream_select($read, $write, $except, $timeout) !== false && count($read) > 0) {
	while($line = fgets($shell)) {
	    echo $line;
	}
}
$elapsed = time() - $start;
var_dump(($elapsed < $timeout));

--EXPECTF--
bool(true)
resource(%d) of type (stream)
%a
%a
%a
howdy
%sbool(true)