473,545 Members | 2,451 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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

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{pri nt@_};sub r($$\$){my($w,$ x,$y)=@_;for(ke ys%$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(ch r(0012))}};t # be*@morrow.me.u k
$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
"Danny" <da********@hot mail.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
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
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
"Danny" <da********@hot mail.com> wrote in message news:<VV******* **************@ news4.srv.hcvln y.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
19329
by: sam | last post by:
I have a function writen in Perl that takes a name-value list (array) as argument and returns a name-value list (array). My question is: How to call this function from PHP and get the returned name-value list in PHP variable? Thanks.
3
3024
by: lonelyplanet999 | last post by:
Hi, I'm a newbie to perl and is now studying about perl programming, I read some perl programming tutorials online (enter 'Perl tutorial' at google.com) and also find some sample perl scripts for study. For below statements I couldn't understand what is the function of '$in'. I tried to search through the perl script tutorial pages since...
5
2663
by: Sue | last post by:
After finishing up my first quarter JavaScript on 12/12/03, I decided to improve character checking on my project. In my project I only had to do very basic validation. Therefore, I only had one function to verify the name fields, age, email and gender. My question is: if I create a function for each field like the code below, what would be...
5
3216
by: Robert Oschler | last post by:
I am converting a Perl script over to "C" for a potential open source project. I need some open source "C" code that will give me the same functionality of a Perl Style associative array: someArray = 6; I know I can't get the same syntactic sugar as Perl offers, with the usage of a string as the array key surrounded by square brackets. ...
7
9914
by: Wladimir Borsov | last post by:
I want to call a perl script myscript.pl in my cgi-bin from a HTML web page. This call should NOT use SSI (because in this case HTTPS://.... protocol is necessary). Furthermore NO button click should be required (so I am not talking about a perl script in a form). I only want to call this script automatically when someone load the web page. ...
1
1633
by: Dave | last post by:
I have "header.html" used by PERL to construct an entire page. Unfortunately, this header page contains no head or body tags; the script generates them. So I am at a loss as to how I can reference 3 external js files to show a js menu in the header page. Nothing I've tried works and I don't want to monkey with the PERL file. If there is a way...
8
2186
by: jonniethecodeprince | last post by:
Hello all. I need to get a html page to work with a PERL script <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" > <head> <title>If's in PERL </title> </head> <body>
1
3121
rajiv07
by: rajiv07 | last post by:
Hi to All, I have try to execute a perl script in html.But nothing get display What i have tried so for is The referrer.pl --------------- #!/usr/bin/perl
1
7170
KevinADC
by: KevinADC | last post by:
Introduction In part one we discussed the default sort function. In part two we will discuss more advanced techniques you can use to sort data. Some of the techniques might introduce unfamiliar methods or syntax to a less experienced perl coder. I will post links to online resources you can read if necessary. Experienced perl coders might find...
0
7487
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7420
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7680
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7934
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7446
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6003
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5349
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3459
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
731
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.