forked from diotteo/TelnetClient.php
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocurvefilter
More file actions
executable file
·46 lines (36 loc) · 812 Bytes
/
procurvefilter
File metadata and controls
executable file
·46 lines (36 loc) · 812 Bytes
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
37
38
39
40
41
42
43
44
45
46
#! /usr/bin/env php
<?php
require_once('AnsiAsciiControlParser.php');
$parser = new AnsiAsciiControlParser();
$f = fopen('php://stdin', 'r');
stream_set_blocking($f, 0);
$a_BACKSPACE_STR = array(
hex2bin('1b5b3f323568'),
hex2bin('1b5b36303b313148'),
hex2bin('1b5b36303b31314820'),
hex2bin('1b5b36303b313148')
);
$parser = new AnsiAsciiControlParser();
$buffer = '';
do {
$s = fgets($f);
$endc = $s[strlen($s) - 1];
if ($s === false) {
//Look for timeout
} else {
$parser->parse($s);
if ($endc === "\n") {
print($buffer);
}
$seqList = $parser->getSequenceList();
foreach ($seqList as $seq) {
$ss = $seq->getString();
if ($seq instanceof TextSequence) {
print($ss);
//} else if ($seq instanceof ControlSequence) {
}
}
}
} while (!feof($f));
fclose($f);
?>