Lorsque vous utilisez popen ou proc_open pour exécuter la commande suivante pour afficher le contenu d'un partage windows:PHP popen et proc_open ne pas retourner la sortie binaire
smbclient -N -U 'username%password' -O 'TCP_NODELAY IPTOS_LOWDELAY SO_KEEPALIVE SO_RCVBUF=8192 SO_SNDBUF=8192' -O 'TCP_NODELAY IPTOS_LOWDELAY SO_KEEPALIVE SO_RCVBUF=8192 SO_SNDBUF=8192' -d 0 '//server/sharename' -c 'dir "dirpath\*"' 2>/dev/null
Si le fichier de la part a le caractère § (ASCII 21 Decimal) lorsqu'il rencontre le caractère spécial, il ignore les données jusqu'à la ligne suivante.
$descriptorspec = array(
0 => array("pipe", "r"), // stdin is a pipe that the child will read from
1 => array("pipe", "wb"), // stdout is a pipe that the child will write to
2 => array("pipe", "w") // stderr is a file to write to
);
$process = proc_open("smbclient -N -U 'username%password' -O 'TCP_NODELAY IPTOS_LOWDELAY SO_KEEPALIVE SO_RCVBUF=8192 SO_SNDBUF=8192' -O 'TCP_NODELAY IPTOS_LOWDELAY SO_KEEPALIVE SO_RCVBUF=8192 SO_SNDBUF=8192' -d 0 '//server/sharename' -c 'dir \"dirpath\*\"' 2>/dev/null", $descriptorspec, $pipes, null, null, array('binary_pipes'=>true));
if(!is_resource($process)) {
return false;
}
echo 'START[['.fread($pipes[1], 10096).']]END';
fclose($pipes[0]);
fclose($pipes[1]);
fclose($pipes[2]);
proc_close ($process);
Résultats escomptés:
. D 0 Fri Feb 5 15:31:11 2010
.. D 0 Fri Feb 5 15:31:11 2010
Test File § hello.doc A 233472 Wed Feb 3 15:16:26 2010
test.xls 11776 Tue Feb 24 11:14:28 2009
réel Sortie:
. D 0 Fri Feb 5 15:31:11 2010
.. D 0 Fri Feb 5 15:31:11 2010
Test File test.xls 11776 Tue Feb 24 11:14:28 2009