-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.php
177 lines (138 loc) · 3.09 KB
/
test.php
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<?php
# Id: $
require_once './eSystem.php';
$e = new eSystem;
/*
* GETOPT test
*/
echo "\n";
echo "-- Getopt Test -------------------------------------------\n\n";
# init getopt global variables
$longopt = array (
'longa' => 'a',
'longb' => 'b',
'longc' => 'c',
'longd' => 'd'
);
while ( ($opt = $e->getopt ($argc, $argv, "abc:d")) != -1 ) :
switch ($opt) :
case 'a' :
$a++;
break;
case 'b' :
$b++;
break;
case 'c' :
$c = $optarg;
break;
case 'd' :
$d++;
break;
default:
echo "getopt failed. option is abc:d ($opt)\n";
exit (1);
endswitch;
endwhile;
echo "Option a => $a\n";
echo "Option b => $b\n";
echo "Option c => $c\n";
echo "Option a => $d\n";
echo "Optcno => $optcno\n";
echo "Optcmd array:\n";
print_r ($optcmd);
echo "\n";
echo "-- _system test ------------------------------------------\n\n";
/*
* _system test
*/
$v = $e->system ("ls -al", $r);
echo "Last Line: $v\n";
unset ($v);
/*
* _exec test
*/
echo "\n";
echo "-- _exec test --------------------------------------------\n\n";
$v = $e->exec ("ls -al", $o, $err);
print_r ($o);
echo "Last Line : $v\n";
echo "ERROR CODE: $err\n";
/*
* mkdirp_p test
*/
echo "\n";
echo "-- mkdir_p test ------------------------------------------\n\n";
$v = $e->mkdir_p ("./ppp/yyy");
echo "mkdir_p test: ";
if ( $v === true ) {
if ( is_dir ("./ppp/yyy") ) echo "OK";
else echo "Fail";
$v = 'true';
} else {
$v = ( $v === false ) ? 'false' : $v;
}
echo " ==> Return Code: $v\n";
/*
* unlink test
*/
echo "\n";
echo "-- unlink test ------------------------------------------\n\n";
touch ("unlinktest");
$v = $e->unlink ("unlinktests");
$v = ( $v === true ) ? 'true' : ($v === false) ? 'false' : $v;
echo "Unlink unlinktests: $v\n";
$v = $e->unlink ("unlinktest");
$v = ( $v === true ) ? 'true' : ($v === false) ? 'false' : $v;
echo "Unlink unlinktest: $v\n";
$v = $e->unlink ("ppp/yyy");
$v = ( $v === true ) ? 'true' : ($v === false) ? 'false' : $v;
echo "Unlink ppp/yyy: $v\n";
/*
* unlink_r test
*/
echo "\n";
echo "-- unlink_R test ------------------------------------------\n\n";
$v = $e->unlink_r ("ppp");
$v = ( $v === true ) ? 'true' : 'false';
echo "Remove ppp: $v\n";
/*
* tree test
*/
echo "\n";
echo "-- tree test ----------------------------------------------\n\n";
$v = $e->tree (".");
print_r ($v);
/*
* find test
*/
echo "\n";
echo "-- find test ----------------------------------------------\n\n";
$v = $e->find ("."); #, '', false);
print_r ($v);
/*
* color test
*/
echo "\n";
echo "-- color test ---------------------------------------------\n\n";
echo $e->putColor ('Color test red', 'red') . "\n";
/*
* backspace test
*/
echo "\n";
echo "-- backspace test ---------------------------------------------\n\n";
echo "print abcdefghijklmn and backspace 3 times\n";
echo "abcdefghijklmn\n";
echo "abcdefghijklmn";
$e->backSpace (3);
echo "\n";
/*
* man test
*/
echo "\n";
echo "-- man test ---------------------------------------------------\n\n";
echo "bash man path:\n";
print_r ($e->manPath ('bash'));
echo "\n\nview bash man page (wait 3sec)\n";
sleep (3);
echo $e->man ('free', 1);
?>