Showing results for 
Search instead for 
Did you mean: 

shell scripting

Super Advisor

shell scripting

Dear Sirs,

I want to know how to execute a unix command through a browser ?

For example: I want to open a browser and click on some link. The link should go to a unix box and execute a command ( say "bdf"). The output should be displayed in the browser itself.

Please let me know the way how to do it alongwith actual code.

Appreciate your help.

Honored Contributor

Re: shell scripting

Shiv, one possible way of doing this using cgi scripts. You can use Apache as your webserver and write cgi scripts, execute commands thro system("bdf") and store it in a file, display that..

"A ship in the harbor is safe, but that is not what ships are built for"
Acclaimed Contributor

Re: shell scripting

You can do this using CGI programs/scripts.
See this link for more information:

Hope this helps!

There are only 10 types of people in the world -
those who understand binary, and those who don't.

No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! thumb below!   
Honored Contributor

Re: shell scripting

You have to develope a terminal emulator with perl+cgi scripts or| php scripting and put into apache web server.

On getting a command from user input, script will execute and send a result to command line.

Easy to suggest when don't know about the problem!
Esteemed Contributor

Re: shell scripting


You will need a combination of telnet plus some scripting which will write the output to your browser.

CGI will be the best.
Vibhor Kumar Agarwal
Respected Contributor

Re: shell scripting

You can also do this using PHP on top of Apache.

For example the following PHP script:


will execute the command on the server. However in such a case since this comand will be executed with the web servers user rights (unless you configure it to run as root). So, you will not be able to run root commands.

For a more complete solution for system administration try Webmin



Re: shell scripting

If you want to use a browser to run an UNIX-command and shows it output, you will need Perl or PHP on the server in combination with Apache. Check for more information.
Simplicity is too difficult for idiots like you and me...