Kurinchi Blogger Scribbles …


Posts Tagged ‘escapeshellcmd’

May 19
2009

PHP: escapeshellcmd, escapeshellarg

Last updated: May 21st, 2009

escapeshellcmd and escapeshellarg are two commands that are used to escape the defect causing characters that are present in the system command or the arguments that get passed to it respectively. Before passing the commands to the system or exec, the strings get escaped using these commands.

Sample program to demonstrate the usage:

<?php

// shell command
$mycmd = "ls -al";
$returncmd = escapeshellcmd($mycmd);
system($returncmd);

// shell arguments
$myshellargs = "al";
system("ls -".escapeshellargs($myshellargs);
?>

Valid HTML 4.01 Strict  Valid HTML 4.01 Strict