PHP操作shell

1. system 函数 (直接输出执行结果)

<?php

$shell = 'ls';

system($shell);



实例2

<?php

$shell = 'ls';

system($shell, $s);

echo $s //返回执行状态, 成功则返回 0, 不成功则返回127

2. exec函数 (将返回的结果放到数组中)

<?php

$shell = "awk -F '{print $1,$3,$4,$6,$7}' /etc/passwd";

exec($shell, $arr);


print_r($arr);

猜你喜欢

转载自my.oschina.net/u/2494575/blog/1816974