Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
Thread: Using shell access.
07-24-2012, 02:22 AM #1
- Join Date
- Sep 2010
- Thanked 275 Times in 275 Posts
Using shell access.
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.
shell_exec(), exec(), system() and ``;
$size = '800x800'; $my_image = "vacation.jpg";
shell_exec('mogrify -geometry '.$size.' '.$my_image);
`mogrify -geometry $size $my_image`;
`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.