[Xitami] Unconditional execution of a CGI in html.
Stuart Hands
stuart at 7sq.co.uk
Wed Feb 11 23:01:13 CET 2009
Ahh that ol' chestnut! An <img tag is your best method as Magnus said
(Iframes? Noooo!) But this has method has a slight twist to ensure 100%
backwards compatibility with old browsers that get thrown off the rails at
even the hint of css...
<img src="/cgi-bin/yourapp">
Now, and here's the clever part, your CGI is executed a cgi script from the
<img tag - but your problem is that you *have* to return an image (even if
it is just a 1px by 1px transparent gif)
Clear as mud? Well, here's how I'd do it (yes, it's in VB. Pack it in before
you even start with the VB slating!)
'convert the hex values of the hex-coded image to bytes.
ImgHex =
"47494638396101000100800000000000FFFFFF21F90401000000002C0000000001000100000
20144003B"
sImage = ""
For x = 1 To Len(ImgHex) Step 2
sImage = sImage & Chr$("&H" & Mid$(ImgHex, x, 2))
Next x
The next few lines would be your own code. When you're ready to finish up,
just send out...
"Status: 200 OK" & vbCrLf
"Content-type: image/gif" & vbCrLf
sImage
...via your chosen method (writing to cgi_stdout is good enough to)
To make sure that you are indeed sending a blank gif - tag this somewhere to
test:
Open "C:\test.gif" For Output As #1
Print #1, sImage
Close #1
And open test.gif in your favourite paint application. Lo! A 1x1 transparent
gif.
I'm not a hundred percent certain if all of this is my own code or not (I've
thrown together quite a few vb cgi apps now and have pulled this from one of
them). Best guess is that it is - because the coding is somewhat sloppy ;)
Good luck!
Stuart
7sq.co.uk
-----Original Message-----
From: xitami-bounces at lists.xitami.org
[mailto:xitami-bounces at lists.xitami.org] On Behalf Of jglong3 at att.net
Sent: 11 February 2009 21:22
To: Xitami Users General Discussion
Subject: Re: [Xitami] Unconditional execution of a CGI in html.
Hello rolinger,,,,, :) :)
Wow,,,,,THANKS for that quick reply!!!!!
Here is an HTML example:
<html>
.
.
<body>
.
.
HTML1 USE AN HTML STATEMENT TO EXECUTE A CGI PROGRAM and execute it
without using <image,,,>,
HTML2 <a href,,,>, or any HTML that will require the user to poke on
something.
<!-- The use of <image,,,,> creates an undesirable graphic with no
information.-->
<!-- The use of <a href,,,,> or <form field,,,,> requires the user to poke
on something-->
.
.
</body>
</html>
The desire here is not to use any embedded HTML Script (i.e.) java,,,,,,
In the mean time since my last Email ..... I found that the following use of
an <Iframe,,,,> will do the trick:
<iframe style="border: none; overflow: hidden; width: 100px; height: 50px;
padding: 0px; margin: 0px;" src="/cgi-bin/test?Iframe,,,"></iframe>
The above HTML1 and HTML2 lines were replaced by the above <iframe,,,,,>
lines and this works as expected.
The "test" cgi program gets executed, the Xitami desired variables, etc. are
recorded to a file on the Xitami Server. The files expected to be written by
"test" are created with "open append" and contain the information expected.
In this case, the <iframe,,,> creates the standard frame graphic to the Web
Page Browser with the scroll up/down plus nothing is in the iframme.
In the mean time we decided to use the <iframme,,,> to display relative
information sent to stdout by the "test" cgi program with print(i.e.) "Date
and Time of visit". The print to stdout by "test" of this information is
displayed in that iframme graphic at the Browser.
Now, we did find the use of <image,,,,> will execute the "test" cgi but it
displays an unwnated graphic at the Web Page Browser with nothing in that
graphic.
It would be nice to get the "test" to execute and not use any HTML that
creates a graphic (<image> or <iframme>)or requires a user to poke on
something (<a href> or <form field>)etc. using some other HTML.
I tried the <font,,,,,,src="cgi-=bin/test,,,",,,,> but the "test" cgi does
not execute,
also SSI <!--#exec,,,,-->
So, with the <Iframme,,,,> all is now working. Your comments make sense and
these will help to continue trying other HTML to find a way.
THANKS for your comments, help, advise, and time!!!!!!! :) :)
Jerry
-------------- Original message from "rolinger" <rolinger1 at hotmail.com>:
--------------
> I think I get what you are referring to. You are looking to automatically
> have a link/script called from within an existing web page. The 'image'
> rendering example you gave below would be one way to do it. The other way
> is to use javascript to execute during on "onLoad" in the HEAD or in the
> tag itself. Though the javascript method would most likely require
> sending the cgi script to a target iFrame or something. I don't think
there
> is a way to get javascript to render external CGI within the same page
> itself.
>
> However, if you are calling trying to call CGI within a static page, why
not
> just make the whole page dynamic, so that as the page itself is rendered
and
> calling the page counters at the same time.
>
> I use image src=/cgi-bin in two locations on my site, they use perls
Imager
> to create/edit/output images on the fly so they don't have to be stored on
> the harddrive, but realize that if you are calling an image cgi script on
> the fly that it is being called and rendered while the current page is
also
> still being loaded. But AFTER the page if fully loaded there will be no
way
> to automatically call CGI scripts (unless you did a Javascript delayed
timer
> type function).
>
> Links from GETs (href) or POSTs (forms) are called upon user interaction
of
> some sort. Image src=/cgi-bin/etc... might be the only way to do
> this...also realize that SSI is executed, just like an image src=/cgi-bin,
> as the page is rendering - an not after it is rendered.
>
> Even after your second explanation I am still not 100% clear on what it is
> you want...but I hope the above helps.
>
> -R
>
> =========
> "Socialism is the philosophy of failure, the creed of ignorance,
> and the gospel of envy, its inherent virtue is the equal sharing of
misery."
> - Sir Winston Churchill -
> =========
> ----- Original Message -----
> From:
> To: "Xitami Users General Discussion"
> Sent: Wednesday, February 11, 2009 10:37 AM
> Subject: Re: [Xitami] Unconditional execution of a CGI in html.
>
>
> > Hello rolinger and Hogan Courrier ,,,,,, :) :)
> >
> > THANKS for the replies,,,,, :) :)
> >
> >
> > Hogan,,,,,, :) :)
> >
> > I'll give that link a try ----THANKS....!!! :) :) <:)
> >
> >
> >
> > rolinger,,,,,, :) :)
> >
> > For a Web Page that already exists and visited (displayed) by a Browser,
> > it is the HTML code in that Web Page that will force the execution of a
> > CGI without any user action that is required such as the HTML "a
href,,,,"
> > or "form field". Also, even having to use the HTML "image,,,,,"
> > (i.e.)(poking on a link, or entering data to a form field, or the action
> > of an HTML "image,,,,,URL/cgi-bin/program?argument1+Argument2,,,,").
> >
> > It is similar to the execution of a CGI counter. Most of these counters
> > that I have seen use the HTML ""
> > which creates a graphic file containing the counter value where
a,b,c,d,,,
> > control the format of how the counter will display and then outputs that
> > graphic file to the Web Page at the Browser.
> >
> > In this case it is a simple CGI that records Xitami variables, etc. at
the
> > Xitami Server. And, the user of the Browser does not have to poke on any
> > item (link, etc.)in the display of the Web Page for that CGI to execute.
> > And, the HTML does not use any "Image,,,,," to execute the CGI.
> >
> > If you want I can send you an example of what has been tried. We even
> > tried to see if SSI would work in the HTML of that Web Page such as:
> >
> >
> >
> >
> >
> > Thanks for your time, help, and advice!!!! :) :)
> >
> > Jerry
> >
> >
> > -------------- Original message from "rolinger"
> > : --------------
> >
> >
> >> What do you mean 'unconditionally execute a cgi program without user
> >> interaction' ???
> >>
> >> CGI execution can only happen if someone goes to a website or clicks a
> >> link
> >> within a website. I suppose you could make automated calls via
javascript
> >> with onMouseOver, or onMouseOut (or even a few other ones). However,
all
> >> those techniques still require a user visiting the webpage just to
> >> initialize those actions.
> >>
> >> Please rephrase, clearly, what is you are looking to do.
> >>
> >> =========
> >> "Socialism is the philosophy of failure, the creed of ignorance,
> >> and the gospel of envy, its inherent virtue is the equal sharing of
> >> misery."
> >> - Sir Winston Churchill -
> >> =========
> >> ----- Original Message -----
> >> From:
> >> To:
> >> Sent: Tuesday, February 10, 2009 2:21 PM
> >> Subject: [Xitami] Unconditional execution of a CGI in html.
> >>
> >>
> >> >
> >> > Hello,,,,, :) :)
> >> >
> >> > I tried to find a search method to look in the Xitami Archives for
the
> >> > situation described below with no luck.
> >> >
> >> > As a newbie using Xitami and Web Pages I have some experience but not
a
> >> > lot of day-to-day activity working with Xitami and/or HTML to find a
> >> > solution for the following.
> >> >
> >> > I was looking for the method in HTML to unconditionally execute a cgi
> >> > program
> >> > in html without user action (i.e.) using an "image", "a href", "form
> >> > field", etc.
> >> >
> >> > The intent is to record Xitami variables, etc. to a file on the
server
> >> > when the page is accessed plus in some cases output text to the
Browser
> >> > window that has accessed that Web Page .
> >> >
> >> > Several methods were found on a google search showing SSI,
etc.(#exec,
> >> > etc.) and none seem to work.
> >> >
> >> > The cgi program can be executed with the entry to the Browser address
> >> > window of:
> >> >
> >> >
http://IP_of_Xitami/cgi-bin/TEST_CGI_PROGRAM?Argument1+Argument2,,,,,,,
> >> >
> >> > And, the cgi programm runs as expected with the arguments found and
> >> > recorded as well as a display of text to the Browser window where the
> >> > above http:// is entered.
> >> >
> >> > The ADMIN of Xitami was used to review the settings for that WEB Page
> >> > CGI
> >> > and
> >> > these seem to be set to cause this to happen for that WEB Page. But,
I
> >> > am
> >> > not
> >> > sure if a settings is required and has been overlooked and needs to
be
> >> > set
> >> > to
> >> > cause this to happen.
> >> >
> >> > Or, the HTML code to cause this to happen has not been used properly
in
> >> > the HTML
> >> > code of that WEB Page.
> >> >
> >> > THANKS for your time, help, and advice!!!! :) :)
> >> >
> >> > Jerry
> >
> >
> > --
> > Xitami Users Mailing List -- For Xitami support
> > To unsubscribe: http://lists.xitami.org/mailman/listinfo/xitami
> >
>
>
>
> --
> Xitami Users Mailing List -- For Xitami support
> To unsubscribe: http://lists.xitami.org/mailman/listinfo/xitami
--
Xitami Users Mailing List -- For Xitami support
To unsubscribe: http://lists.xitami.org/mailman/listinfo/xitami
More information about the Xitami
mailing list