1748150 Members
3678 Online
108758 Solutions
New Discussion юеВ

Re: shell scripting

 
Shivkumar
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.

Thanks,
Shiv
6 REPLIES 6
Arunvijai_4
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..

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

Re: shell scripting

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

http://httpd.apache.org/docs/2.0/howto/cgi.html

Hope this helps!
Regards
Torsten.

__________________________________________________
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!   
Muthukumar_5
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.

hth.
Easy to suggest when don't know about the problem!
Vibhor Kumar Agarwal
Esteemed Contributor

Re: shell scripting

Yes,

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
Orhan Biyiklioglu
Respected Contributor

Re: shell scripting

You can also do this using PHP on top of Apache. http://h20293.www2.hp.com/portal/swdepot/displayProductInfo.do?productNumber=HPUXWSAP4381

For example the following PHP script:

system("command");
?>

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

hth

Kryno Bosman
Advisor

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 http://www.php.net for more information.
Simplicity is too difficult for idiots like you and me...