[root@dywang tmp]# visudo [root@dywang tmp]# grep apache /etc/sudoers apache ALL=(ALL) NOPASSWD:/usr/sbin/chroot
[root@dywang tmp]# cat /etc/hosts 127.0.0.1 dywang localhost localhost.localdomain dywang.csie.cyut.edu.tw ::1 localhost localhost.localdomain 163.17.10.68 dywang.csie.cyut.edu.tw #%* 加入主機名稱與 ip 對應*)
[root@dywang tmp]# cat yes.php
<?php
system('yes');
?>
[root@dywang tmp]# cat yest.php
<?php
system('timeout 1s yes');
?>
[root@dywang tmp]# cat yest.php
[root@dywang tmp]# php yest.php
y
y
y
y
y
[root@dywang tmp]# vim exehead.php
[root@dywang tmp]# cat exehead.php
<?php
exec('timeout 1s yes | head -c 10', $results);
print_r($results);
?>
[root@dywang tmp]# php exehead.php
yes: standard output: Broken pipe
yes: write error
Array
(
[0] => y
[1] => y
[2] => y
[3] => y
[4] => y
)