Running a CGI Counter Script

M

Mark Hobley

I have created an HTML page as follows:

<!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en">
<html>
<title>Test Page</title>
</head>
<body>
<!--#include virtual="/cgi-bin/count.cgi?testcount"-->
</body>
</html>

I was expecting this to invoke my count.cgi script, but it does not run.

If I point the browser at /cgi-bin/count.cgi, the script runs as expected.

Have I used the HTML correctly ?

Please advise.
My web server daemon is thttpd.

Mark.

--
Mark Hobley
393 Quinton Road West
QUINTON
Birmingham
B32 1QE

Telephone: (0121) 247 1596
International: 0044 121 247 1596

Email: markhobley at hotpop dot donottypethisbit com

http://markhobley.yi.org/
 
M

Mark Hobley

In alt.html David Dorward said:
That is SSI rather then HTML. The syntax looks correct.

Ok. Is there an HTML way of doing this ? I just want the script to run as the
page is viewed.
Are you accessing the page using the ssi CGI program?
http://www.acme.com/software/thttpd/ssi_man.html

My scripts that collect form data work ok. Its just the counter script that
doesn't run. Can I invoke the hit counter without ssi ?

Mark.

--
Mark Hobley
393 Quinton Road West
QUINTON
Birmingham
B32 1QE

Telephone: (0121) 247 1596
International: 0044 121 247 1596

Email: markhobley at hotpop dot donottypethisbit com

http://markhobley.yi.org/
 
D

David Dorward

Mark said:
Ok. Is there an HTML way of doing this ? I just want the script to run as
the page is viewed.

<img src="/cgi-bin/myscript.cgi" alt="">

.... and then ensure that myscript.cgi returns an image.

It will break if images are turned off.
Its likely to break with some privacy packages.
It means another http request for each page view.

You could also switch to a webserver which supports SSI internally, such as
Apache.
 
M

Mark Hobley

Mark Hobley said:
My scripts that collect form data work ok. Its just the counter script that
doesn't run. Can I invoke the hit counter without ssi ?

I have found that instead of using the following:

<!--#include virtual="/cgi-bin/count.cgi?testcount"-->

I can use:

<img src="/cgi-bin/count.cgi?testcount">

This runs the script.

Unfortunately, my script doesn't produce an image, so I get a rectange on the
screen where the image would go.

Can I use instead something like one of the following:

<text src="/cgi-bin/count.cgi?testcount">

or even better

<void src="/cgi-bin/count.cgi?testcount">

or

<null src="/cgi-bin/count.cgi?testcount">

?

Please advise.

Mark.

--
Mark Hobley
393 Quinton Road West
QUINTON
Birmingham
B32 1QE

Telephone: (0121) 247 1596
International: 0044 121 247 1596

Email: markhobley at hotpop dot donottypethisbit com

http://markhobley.yi.org/
 
D

David Dorward

Mark said:
<img src="/cgi-bin/count.cgi?testcount">
Unfortunately, my script doesn't produce an image, so I get a rectange on
the screen where the image would go.
Can I use instead something like one of the following:

<text src="/cgi-bin/count.cgi?testcount">

No. Change the script so it outputs an image - but see my previous comments
on the subject elsewhere in this thread.
 
M

Mark Parnell

Unfortunately, my script doesn't produce an image, so I get a rectange on the
screen where the image would go.

Change the script?
<text src="/cgi-bin/count.cgi?testcount">
<void src="/cgi-bin/count.cgi?testcount">
<null src="/cgi-bin/count.cgi?testcount">

Considering <text>, <void> and <null> don't exist, no. Well, there's
nothing stopping you from putting it into your page, but any browser
that did anything with it would be misbehaving.

Apart from getting the cgi to return an image (noting the caveats
mentioned by David), the only reliable way of including it would be
through SSI (or PHP, ASP etc.).
 
J

Jonathan N. Little

Mark said:
I have created an HTML page as follows:

<!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en">
<html>
<title>Test Page</title>
</head>
<body>
<!--#include virtual="/cgi-bin/count.cgi?testcount"-->
</body>
</html>

The code above is a SSI, Server Side Include, most hosting company
servers settings require the file extension 'shtml'. So if you have the
above code in your html document 'mypage.html' rename to 'maypage.shtml'
and see if it works.
 
M

Mark Hobley

David Dorward said:
<img src="/cgi-bin/myscript.cgi" alt="">

... and then ensure that myscript.cgi returns an image.

I think that I might be able to get a 1 x 1 transparent gif from somewhere.

How would I send it from the script, which is a conventional unix script that
will run on a Bourne compatible shell?

Mark.

--
Mark Hobley
393 Quinton Road West
QUINTON
Birmingham
B32 1QE

Telephone: (0121) 247 1596
International: 0044 121 247 1596

Email: markhobley at hotpop dot donottypethisbit com

http://markhobley.yi.org/
 
G

Guillaume

David Dorward:
Mark Hobley:
I think that I might be able to get a 1 x 1 transparent gif from somewhere.
How would I send it from the script, which is a conventional unix script that
will run on a Bourne compatible shell?

#!/bin/sh

echo 'Content-Type: image/gif'
echo

# counting code here

cat image1x1.gif


You can add more options like Pragma: no-cache, Content-Length, ...
 
N

Neredbojias

With neither quill nor qualm, Mark Hobley quothed:
I have found that instead of using the following:

<!--#include virtual="/cgi-bin/count.cgi?testcount"-->

I can use:

<img src="/cgi-bin/count.cgi?testcount">

This runs the script.

Unfortunately, my script doesn't produce an image, so I get a rectange on the
screen where the image would go.

Style it invisible or "display:none;"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top