Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to embedd cgi in html

Tags:

html

cgi

I have no problem executing a cgi file under the normal url like this:

http://www.myhost.com/mydir/cgi-bin/test.cgi

However when I tried to embedd it into HTML file (called index.html) like this:

<HTML>
   <BODY>
   <P>Here's the output from my program:
   <FORM ACTION="/var/www/mydir/cgi-bin/test.cgi" METHOD=POST>

   <!-- This doesn't work also -->
  <!-- FORM ACTION="cgi-bin/test.cgi" METHOD=POST-->

   </FORM>
   </P>
   </BODY>
</HTML>

The CGI doesn't get executed when I do:

http://www.myhost.com/mydir/index.html

The CGI file (test.cgi) simply looks like this:

#!/usr/bin/perl -wT
use CGI::Carp qw(fatalsToBrowser);
print "Test cgi!\n";

What's the right way to do it?

like image 555
neversaint Avatar asked May 07 '26 05:05

neversaint


2 Answers

The problem is the path you are providing in the action property of the form.

You need to change it to be a path relative to the current document. (index.html)

From your example, it looks like this would be cgi-bin/test.cgi

like image 184
Nathan Osman Avatar answered May 08 '26 22:05

Nathan Osman


There isn't a good way to do this in HTML. It is a job better suited for SSI using an exec or virtual directive.

like image 45
Quentin Avatar answered May 08 '26 20:05

Quentin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!