How to embed cgi in html

I have no problem executing the cgi file under the regular url as follows:

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

However, when I tried to insert it into an HTML file (called index.html) as follows:

<HTML>
   <BODY>
   <P>Here 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>

CGI fails when I do:

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

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

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

What is the right way to do this?

+3
source share
4 answers

The problem is the path you provide in the actionform property .

You need to change it as the path to the current document. ( index.html)

In your example, it looks like cgi-bin/test.cgi

+2
source

HTML . , SSI, exec .

+2

Use patterns. It is a bad idea to combine different codes. Even JS and CSS are separated from (X) HTML for readability and maintenance.

+1
source

You tried to use iframe:

<HTML>
   <BODY>
   <P>Here the output from my program:
   <iframe src="http://www.myhost.com/mydir/cgi-bin/test.cgi" />
   </P>
   </BODY>
</HTML>
0
source

Source: https://habr.com/ru/post/1742394/


All Articles