Re: shell scripting (606 Views)
Super Advisor
Posts: 1,207
Registered: ‎05-22-2005
Message 1 of 7 (606 Views)

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
Posts: 4,194
Registered: ‎04-07-2005
Message 2 of 7 (606 Views)

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
Posts: 24,037
Registered: ‎10-02-2001
Message 3 of 7 (606 Views)

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
Posts: 4,030
Registered: ‎06-09-2004
Message 4 of 7 (606 Views)

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
Posts: 787
Registered: ‎04-05-2005
Message 5 of 7 (606 Views)

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
Posts: 153
Registered: ‎09-12-2005
Message 6 of 7 (606 Views)

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


Posts: 12
Registered: ‎01-26-2004
Message 7 of 7 (606 Views)

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...
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.