<?php
$descriptorspec = array(
1 => array('pipe', 'w'),
2 => array('pipe', 'w'),
);
$pipes = array();
$command = "cp -r /源文件目錄/* /目標文件目錄";
$resource = proc_open($command, $descriptorspec, $pipes);php
$stdout = stream_get_contents($pipes[1]);
$stderr = stream_get_contents($pipes[2]);
foreach ($pipes as $pipe) {
fclose($pipe);
}ide
$status = trim(proc_close($resource));code
若是成功$status爲0,$stdout是命令輸出;失敗則$status爲錯誤code,$stderr爲對應錯誤信息字符串ip