Write a Script to Run Shell Commands from Browser

It happens pretty often for me to have to run shell commands in a hosting environment. I do it all the time via a simple php script. I tested it on godaddy and dreamhost and on other hostings environments and it works fine. Before starting the tutorial you should note that if this script is not handled carefully it can have undesired results. A wrong rm command can delete all the files you have on your hosting, so run the commands with care.

Related Tutorials
Exec and system command and results
This tutorial will show you how to run exec commands and system commands from php using a form, you do not need a database to run these commands but you do need permission to be able to run command line commands from PHP. This tutorial will show you how to do this using an example with the "ping" command, in short we will go through how to ping and display the results via browser.
Apache Server PHP MySQL phpMyAdmin Setup using AppServ
Our goal is to be able to run PHP scripts on our own computers for the purpose of dynamic web testing and development. What exactly should you do to get the scripts run properly? Unlike running general HTML scripts in IE or any other browser, running PHP requires some components for the script compilation. The answer to this question is by installing a web server (Apache), PHP Core, and MySQL (for database-driven websites) on your PC.
Storing Data in the Client
One of the things that all programmers love is to write a program which writes another program. On the web we have two different programming environments: the client (browser) and the server. Due to the HTTP protocol definition we can write a program on the server which writes another program to be executed on the client. Let's pick PHP (of course) for the server and JavaScript for the client. We'll show you in this article how you can use this scheme to store data in the client and then minimize the data transfered between the server and the browser for interactive applications like a chat room, a news system or whatever you want.
Restricting External Access to .PHP Files
Sometimes, when you are writing your PHP script, you'll write Classes and Functions that you will use in your script in external files so that they might be included( ) or required( ) at any time. The same could be said about configuration files - You have certain settings in the form of variables in a external configuration file that you load in the different pages of your script so that they might be shared and edited with ease.
Writing Your First PHP Script: Feedback Form
This is a tutorial on how to write your own Feedback script in PHP, complete with source code.
Importing csv data into MySQL with php script
This tutorial will show you how to import csv data into MYSQL with a simple PHP script. Many times you have to write a script because the import function in phpMyAdmin will not import the way you want.
PHP Lesson 1 - First PHP Script
In this tutorial you will learn how to run a PHP script.
How to Write a PHP Script to Send a Trackback
Creating a php script to send a trackback HTTP request to a blog, read the response, and let the user know whether or not the trackback was successful.
Basic Poll Script in PHP
This article will teach you how to write a basic poll script in php. You will use mysql and a new version of PHP.
Simple reusable PHP/MySQL authentication script
We will write a simple PHP/MySQL authentication script that can be reused for any of your project.
 
Categories