By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,632 Members | 1,425 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,632 IT Pros & Developers. It's quick & easy.

How to call a perl script that returns nothing in an HTML

P: n/a
Newbie here
Thanks for the help with this command:

print "Status: 204 No Content\n\n";
which returns nothing in a perl script.

This is great because I just want my perl script to increment a counter and put result in a text file which it does fine how.
But now how do I call this from an .html? I used to call it like this
<img src="path to cgi script">
this increments the counter but there is a little box where an actual image should be, so how do I:
1. have the script return a bogus image (using below)
print "Content-type: image/gif\n\n";
(not sure how I would print a graphic here)
2. or have the call html file run this script somehow without using the image tag so I dont get that little empty graphic display.

Thanks in advance

Jul 20 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Danny wrote:
Newbie here
So what? ;-)
Thanks for the help with this command:

print "Status: 204 No Content\n\n";
which returns nothing in a perl script.
You're welcome, but you should have replied to a message in the same
thread instead of starting a new thread.
This is great because I just want my perl script to increment a
counter and put result in a text file which it does fine how.
But now how do I call this from an .html? I used to call it like
this <img src="path to cgi script">
Aha. I took for granted that the script was invoked through SSI.
this increments the counter but there is a little box where an
actual image should be, so how do I:
1. have the script return a bogus image (using below)

print "Content-type: image/gif\n\n";
(not sure how I would print a graphic here)
Personally I haven't played much with images, but I suppose you can
do:

print "Content-type: image/gif\n\n";
open IMG, '< /path/to/blank.gif' or die "Couldn't open image $!";
print while <IMG>;
2. or have the call html file run this script somehow without using
the image tag so I dont get that little empty graphic display.


You can invoke it via SSI:

<!--#exec cgi="path to cgi script" -->

Note that the HTML file may need to have the extension .shtml for that
to work. (And SSI must be enabled on the server, of course.)

Have you considered to use some other counter script that does not
make use of any executable? Or write your own?

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Jul 20 '05 #2

P: n/a
Gunnar Hjalmarsson wrote:

print "Content-type: image/gif\n\n";
open IMG, '< /path/to/blank.gif' or die "Couldn't open image $!";
print while <IMG>;


Should better be:

print "Content-type: image/gif\n\n";
open IMG, '< /path/to/blank.gif' or die "Couldn't open image $!";
binmode IMG;
print while <IMG>;

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Jul 20 '05 #3

P: n/a

Gunnar Hjalmarsson <no*****@gunnar.cc> wrote:
Gunnar Hjalmarsson wrote:

print "Content-type: image/gif\n\n";
open IMG, '< /path/to/blank.gif' or die "Couldn't open image $!";
print while <IMG>;
Should better be:

print "Content-type: image/gif\n\n";
open IMG, '< /path/to/blank.gif' or die "Couldn't open image $!";
binmode IMG;


binmode STDOUT;
$/ = \4096; # or some such: no point reading a binary file by lines
print while <IMG>;


Or use IO::SendFile (if you can).

Ben

--
$.=1;*g=sub{print@_};sub r($$\$){my($w,$x,$y)=@_;for(keys%$x){/main/&&next;*p=$
$x{$_};/(\w)::$/&&(r($w.$1,$x.$_,$y),next);$y eq\$p&&&g("$w$_")}};sub t{for(@_)
{$f&&($_||&g(" "));$f=1;r"","::",$_;$_&&&g(chr(0012))}};t # be*@morrow.me.uk
$J::u::s::t, $a::n::o::t::h::e::r, $P::e::r::l, $h::a::c::k::e::r, $.
Jul 20 '05 #4

P: n/a
"Danny" <da********@hotmail.com> wrote:
Thanks for the help with this command:

print "Status: 204 No Content\n\n";
which returns nothing in a perl script.
I guess you have a somewhat unusual definition of "return".
If you are talking about "the command doesn't produce any output" then you
are wrong. Obviously print() prints something.
If you are talking about the return value of the print statement then you
are wrong again:
print [...] Returns true if successful.
If you are talking about the return value of the program then, well, you are
right. If you want that then you need to use the exit() command.

So, what "return" are you talking about?
This is great because I just want my perl script to increment a counter
and put result in a text file which it does fine how.
Ok, then I guess you don't have a Perl problem.
But now how do I call this from an .html? I used to call it like
this
<img src="path to cgi script">


Ahhh, ok, this is a disguised CGI question.
Please see "perldoc -q 500" (althought that answer seems to address a
different problem it applies to your question, too.)

jue
Jul 20 '05 #5

P: n/a
Ben Morrow wrote:
Gunnar Hjalmarsson wrote:

print "Content-type: image/gif\n\n";
open IMG, '< /path/to/blank.gif' or die "Couldn't open image $!";
binmode IMG;
binmode STDOUT;


Ouch! Still missed that. Thanks!
$/ = \4096; # or some such: no point reading a binary file by lines


Well, in this case we are probably talking about a 1px x 1px image.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Jul 20 '05 #6

P: n/a
On Wed, 11 Feb 2004 16:27:48 +0100, Gunnar Hjalmarsson
<no*****@gunnar.cc> wrote:
Ben Morrow wrote:
$/ = \4096; # or some such: no point reading a binary file by lines


Well, in this case we are probably talking about a 1px x 1px image.


Yes, but there's still no point in parsing the buffer for \n characters
in binary data.

(I probably would've used something like "read IMG, $buf, -s IMG; print
$buf" to read the whole thing in one go.)

Cheers,
Philip
--
Philip Newton <no***********@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
Jul 20 '05 #7

P: n/a
"Danny" <da********@hotmail.com> wrote in message news:<VV*********************@news4.srv.hcvlny.cv. net>...
Newbie here
Thanks for the help with this command:

print "Status: 204 No Content\n\n";
which returns nothing in a perl script.

This is great because I just want my perl script to increment a counter
and put result in a text file which it does fine how.
But now how do I call this from an .html? I used to call it like this
<img src="path to cgi script">
this increments the counter but there is a little box where an actual
image should be, so how do I:
1. have the script return a bogus image (using below)
print "Content-type: image/gif\n\n";
(not sure how I would print a graphic here)
2. or have the call html file run this script somehow without using the
image tag so I dont get that little empty graphic display.

Thanks in advance

--


The following img tag should not display anything on the page and will
call the CGI as desired...

<img src="<cgi script>" height="0" width="0" border="0">
Jul 20 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.