How can i write a script to execute commands on the webserver from a browser?

I want to create a script with the php exec() or system() function to execute commands from a remote browser on the webserver. I am open to using Perl or whatever. I am using an Apache2 webserver on Ubuntu.

I have done quite a bit of research on this on google and read lots of responses about permissions of the server, why not use ssh instead etc. etc..

I know of other ways to do this but I am really interested in how I can make this work from the browser. Thanks in advance.