Running a CGI Counter Script

Discussion in 'HTML' started by Mark Hobley, Dec 7, 2005.

  1. Mark Hobley

    Mark Hobley Guest

    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/
     
    Mark Hobley, Dec 7, 2005
    #1
    1. Advertising

  2. Mark Hobley wrote:

    > <!--#include virtual="/cgi-bin/count.cgi?testcount"-->
    > Have I used the HTML correctly ?


    That is SSI rather then HTML. The syntax looks correct.

    > My web server daemon is thttpd.


    Are you accessing the page using the ssi CGI program?
    http://www.acme.com/software/thttpd/ssi_man.html


    --
    David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
    Home is where the ~/.bashrc is
     
    David Dorward, Dec 7, 2005
    #2
    1. Advertising

  3. Mark Hobley

    Mark Hobley Guest

    In alt.html David Dorward <> wrote:

    > 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/
     
    Mark Hobley, Dec 7, 2005
    #3
  4. Mark Hobley wrote:

    > In alt.html David Dorward <> wrote:
    >
    >> 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.


    <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.

    --
    David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
    Home is where the ~/.bashrc is
     
    David Dorward, Dec 7, 2005
    #4
  5. Mark Hobley

    Mark Hobley Guest

    Mark Hobley <> wrote:

    > 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/
     
    Mark Hobley, Dec 7, 2005
    #5
  6. Mark Hobley wrote:

    > <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.

    --
    David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
    Home is where the ~/.bashrc is
     
    David Dorward, Dec 7, 2005
    #6
  7. Mark Hobley

    Mark Parnell Guest

    In our last episode, Mark Hobley <>
    pronounced to alt.html:

    > 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.).

    --
    Mark Parnell
    http://clarkecomputers.com.au
     
    Mark Parnell, Dec 7, 2005
    #7
  8. Mark Hobley wrote:
    > 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.


    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
     
    Jonathan N. Little, Dec 7, 2005
    #8
  9. Mark Hobley

    Mark Hobley Guest

    David Dorward <> wrote:

    > <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/
     
    Mark Hobley, Dec 8, 2005
    #9
  10. Mark Hobley

    Guillaume Guest

    > David Dorward:
    >><img src="/cgi-bin/myscript.cgi" alt="">
    >>... and then ensure that myscript.cgi returns an image.


    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, ...

    --
    My desktop is worth a million of dollars. Put an icon on it.
    http://www.milliondollarscreenshot.com/
     
    Guillaume, Dec 8, 2005
    #10
  11. Mark Hobley

    Neredbojias Guest

    With neither quill nor qualm, Mark Hobley quothed:

    > Mark Hobley <> wrote:
    >
    > > 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.


    Style it invisible or "display:none;"

    --
    Neredbojias
    Contrary to popular belief, it is believable.
     
    Neredbojias, Dec 9, 2005
    #11
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. The Eeediot
    Replies:
    3
    Views:
    2,250
    =?Utf-8?B?UnVsaW4gSG9uZw==?=
    Dec 22, 2004
  2. George2
    Replies:
    1
    Views:
    809
    Alf P. Steinbach
    Jan 31, 2008
  3. rodmc

    Running CGI from within CGI

    rodmc, Feb 14, 2008, in forum: Python
    Replies:
    3
    Views:
    411
    Bruno Desthuilliers
    Feb 14, 2008
  4. T Stewart

    Problem with counter CGI script

    T Stewart, Jul 5, 2003, in forum: Perl Misc
    Replies:
    1
    Views:
    223
    Gunnar Hjalmarsson
    Jul 7, 2003
  5. kath
    Replies:
    4
    Views:
    669
    J. Gleixner
    Apr 9, 2007
Loading...

Share This Page