dittbub Posted February 20, 2004 Share Posted February 20, 2004 Could you give me a small example of what a cgi script would look like just to display a simple linux command in a webpage. say, i want a webpage to show who is logged in on the network. Link to comment Share on other sites More sharing options...
0 MrStaticVoid Posted February 20, 2004 Share Posted February 20, 2004 (edited) What do you mean no Perl? Perl is the most common type of CGI. You could do it very simply in sh, AFAIK. #!/bin/sh echo "<html>" echo "<body><pre>`w`</pre></body>" echo "</html>" As you see, when put into the console, those commands produce: jlee@jlee jlee $ echo "<html>" && echo "<body><pre>`w`</pre></body>" && echo "</html>"<html> <body><pre> 17:45:21 up 1 day, 2:59, 3 users, load average: 1.70, 1.93, 2.02 USER TTY LOGIN@ IDLE JCPU PCPU WHAT jlee vc/1 Thu14 26:45m 11.15s 0.00s /bin/sh /usr/X11R6/bin/startx jlee pts/0 17:42 0.00s 0.07s 0.05s -bash jlee pts/1 16:44 18:13 28.15s 27.76s timidity -ia reverie.mid</pre></body> </html> Edited February 20, 2004 by Mr. Static Void Link to comment Share on other sites More sharing options...
0 dittbub Posted February 21, 2004 Author Share Posted February 21, 2004 oh thank you! now could you help me better understand using an cgi scrpt in a form? i need a submit button to e-mail the info from the form. the check boxes and radio buttons and whatnot. Link to comment Share on other sites More sharing options...
0 aldo Posted February 21, 2004 Share Posted February 21, 2004 Damn, implementing a email submitter in bash? Nasty. You should really check out PHP, exec() and passthrough() will do all those command line goodness in one command. Link to comment Share on other sites More sharing options...
0 dittbub Posted February 21, 2004 Author Share Posted February 21, 2004 i would do that but i kinda have to do it the way i said if i want to get full marks on my linux labs :( Link to comment Share on other sites More sharing options...
0 MrStaticVoid Posted February 21, 2004 Share Posted February 21, 2004 I don't think bash can handle forms. I may be wrong, but it's a crazy concept. You may need to reconsider languages, even if you won't get the best grade. Link to comment Share on other sites More sharing options...
0 dittbub Posted February 21, 2004 Author Share Posted February 21, 2004 what about perl? Link to comment Share on other sites More sharing options...
Question
dittbub
Could you give me a small example of what a cgi script would look like just to display a simple linux command in a webpage. say, i want a webpage to show who is logged in on the network.
Link to comment
Share on other sites
6 answers to this question
Recommended Posts