1. Shell in a Drupal website
A very useful Drupal module that will give you a command line directly in your site:
1. Install Shell module (can be download here)
2. Activate the module
3. Logged as an administrator, go to your site.com/shell
4. Run your commands just like in a shell.
Important security note: Set permissions to Administrators only, and I would recommend to disable the module when you don’t use it.
2. On any other php sites
Here is a simple php script to upload to your website (with FTP). Once uploaded, launch the page www.mysite.com/run.php and run some commands.
To download the file: http://php-html.net/tutorials/wp-content/uploads/2009/07/simple-run.zip
More information on http://php-html.net/tutorials/how-to-write-a-php-script-to-run-shell-commands-from-browser/
Important security note: Delete or change the extension of the run.php file when not using it!