c'est assez simple en fait.
imaginons la ligne de commande suivante:
toto -f dklfslkjf -j kdfj -name "sjshslfkkj kjshflkdsjh"
d'abord on verifie que apache a le droit d'excuter l'application toto (et peut être qu'on forcera /usr/bin/toto pour être sur.
1 2 3 4 5 6 7 8 9 10 11
| $cmd=escapeshellcmd('/usr/bin/toto').
.' -f '.escapeshellarg('dklfslkjf')
.' -j '.escapeshellarg('kdfj')
.' -name '.escapeshellarg('sjshslfkkj kjshflkdsjh');
exec($cmd, $out, $rc );
echo '<pre>',implode("\n",$out),'</pre>';
if ( $rc > 0 ){
throw new Exception('Commande terminée en erreur (code '.$rc.')');
} |
Partager