I don't know exactly how you do it, but if you wanted, you could write a shell script. Once you have the shell script setup, you could run it and it would run all the commands for you
Here is a site to help you do that:
You could also try writing a perl script and run the commands that way. I don't know the specifics, but there are plenty of tutorials that will tell you how.
This is a short section I found in a Perl For Dummies 3rd Edition by Paul Hoffman:
"Perl makes it easy to run commands on you computer as if you had entered them on the command line. Perl's system
function is designed to execute a command. On a [Linux] system, for example, you can use the system
function execute the 'ls' command."
Here is a sample code snippet:
#list contents of var/www/html folder
system( 'ls -l /var/www/html' );
Of course, to use the Perl system function, you should know perl first. There is a short tutorial on www.devshed.com.
Hope this helps.