The next version of PhP will not include Safe Mode, and if your webhost updates to it you will have shell access. Most servers now use Apache, or at least a server that is on a 'nix ( linux, Unix, BSD ) host so you will have access to the BASH shell and other shells. Even Mac has the BASH shell, so if you have a home server you may have access now. There are several ways to call the shell with php, they differ slightly.
The last one is 'backslash notation' it's the key right above the tab key on most machines. It's the one I prefer, it's the simplest to use and the code is much cleaner.
shell_exec(), exec(), system() and ``;
Notice that with the backslash you don't need the periods to join the string. You don't need them at all as the shell just reads the whole line as a single string and the application executes it. You can call shell scripts with it.
$size = '800x800'; $my_image = "vacation.jpg";
shell_exec('mogrify -geometry '.$size.' '.$my_image);
`mogrify -geometry $size $my_image`;
NEVER put the backslashes or exec commands around input or textarea data, because it gives someone complete access to your machine. Always feed it to an application or filter it before sending it to the shell.
`bash myscript.sh $input`;
One of my favorite shell apps is 'while read' it just reads a text file line by line and executes whatever you tell it for that line. So you just make up a simple list with the last line empty. You write a script with the code you want run and you use your list as the input for the script. Simple to use, gives you complete control over what is happening, nice for use on a server.
Here's a nice page which gives a good summary of the BASH commands.