• 0

CGI with Linux


Question

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

  • 0

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 by Mr. Static Void
Link to comment
Share on other sites

  • 0

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

  • 0

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

  • 0

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

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.