Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gmmastros on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

calling perl script from html 1

Status
Not open for further replies.

abovebrd

IS-IT--Management
May 9, 2000
690
0
0
US
I created a simple counter script that I want to display and execute via an html page. I am able to get the perl script to execute when directly accessed but not from a seperate html page

How do I call the script from an html page and display its output.

Here is the perl code I was using:
#!/usr/bin/perl

use CGI qw:)standard);
open(COUNT, &quot;< count.log&quot;);
chomp($var=<COUNT>);
close(COUNT) ;
$var=$var+1;
open(COUNT1, &quot;> count.log&quot;);
print COUNT1 &quot;$var\n&quot;;
close(COUNT1);

print &quot;Content-type: text/html\n\n&quot;;
print &quot;You are visitor $var&quot;;

Here is the simple html page I was try to use

<HTML>
<HEAD>
<TITLE> Counter </TITLE>
</HEAD>
<BODY>
<H1> COUNTER SCRIPT </H1>
<img src=&quot;/cgi-bin/counter.pl&quot;>
</BODY>
</HTML>
~

Please set set me straight.




-Danny






 
hi

if u want to call the perl file from html document than u just have to do one thing
for example
in try.cgi

#!/usr/bin/perl -w
print &quot;content/type html \n\n&quot;;

print <<HEADER(or any name)

<html><head><title></title>
whole html code
HEADER
;
call perl file here
and u will get the result

bharat
indiabhushan@usa.net
 

I can't tell if you're on an MS server or Unix based but if you have SSI (Server Side Includes) enabled on your server you can use an ssi call so run your script.

<!--#exec cgi=&quot;/cgi-bin/counter.pl&quot; -->

You'd also usually have to rename your .html page to .shtml

Also, another way you could do it is with a small 1 X 1 pixle iframe.

<iframe src=&quot;/cgi-bin/counter.pl&quot; width=1 height=1 marginwidth=0 marginheight=0 hspace=0 vspace=0 frameborder=0 scrolling=no></iframe>

That would run it from any type of page, regardless of your server.

Tony
 
sleuth,

Its a unix box running apache. I do I SSI enabled. I will give it a try. Thanks for the pointers. I'll post back how it worked.

-Danny






 
sleuth,

Its a unix box running apache. I do I SSI enabled. I will give it a try. Thanks for the pointers. I'll post back how it worked.

-Danny






 
OK

I changed the page to .shtml (I should have known that !)

And added the exec cgi statement.
<!--#exec cgi=&quot;counter.pl&quot; -->

It seems that my counter script is now working !!

Thanks for the pointers.


-Danny






 
I also tried the <iframe> tag

Thats was a cool work around in place of using SSI.

Thanks

Both options worked well



-Danny






 

Glad to hear it Mate,

Tony

&quot;I'm starting to like this forum&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top