You aren't printing a response header. That might be a problem. Then
again, it might not.

More importantly, you aren't using "use strict" and "use warnings", which
will catch many errors for you. The first thing you should do is ask Perl
to help you, by including use strict and use warnings.

> As you can see I am calling test3.cgi as my image. Here is my code in
> test3.cgi :
>
> #!/usr/bin/perl
> use CGI;
>
> print header;

What do you expect this to do? Are you sure it is doing it?
> print "Content-type: image/gif\n\n";

How do you think this will interact with the previous line?
> print "<img src=\"/images/angry.gif\">";

You told it that the content type was an image/gif, but now you are sending
it html, which is not image/gif.
>
> When I try opening up test.cgi, I don't get ANY IMAGE outputted to my
> browser.

So, what *do* you see? A broken image icon? A 500 error?

Xho

--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.

Advertisements

Thanks Xho for quick reply, while i was trying to get this going I was
trying too many things that is why the code is out of whack but here is
a good example of what I am doing now and its the same result (NO IMAGE).

call_image.cgi:

#!/usr/bin/perl -wT

print "Content-type: text/html\n\n";

print "<HTML>
<BODY>
<IMG SRC=\"show_image.cgi\">
</BODY>
</HTML>" ;

show_image.cgi:

#!/usr/bin/perl -wT

print "Content-type: image/gif\n\n";
print "<img src=\"angry.gif\">";

The image resides in the same directory as all the cgi scripts.

This is part of bigger code that I am writing to display CAPTCHA images
but for some reason I cannot get the image rendered on the "call_image.cgi"

fyi: I am on a macbook and using macports version on apache. Not the
one that comes built in.

Thanks for your help.

-Parvinder Bhasin

wrote:
> secSwami <> wrote:
>> I am messing around with cgi and perl. I have a cgi page test.cgi with
>> following code:
>>
>> #!/usr/bin/perl
>>
>> print "<html>
>> <head>
>> <title>TEST CAPTCHA IMAGE Verification</title>
>> </head>
>>
>> <body>
>> <img src=\"/cgi-bin/test3.cgi\">
>> </body>
>> </html>";
>
> You aren't printing a response header. That might be a problem. Then
> again, it might not.
>
> More importantly, you aren't using "use strict" and "use warnings", which
> will catch many errors for you. The first thing you should do is ask Perl
> to help you, by including use strict and use warnings.
>
>
>> As you can see I am calling test3.cgi as my image. Here is my code in
>> test3.cgi :
>>
>> #!/usr/bin/perl
>> use CGI;
>>
>> print header;
>
> What do you expect this to do? Are you sure it is doing it?
>
>> print "Content-type: image/gif\n\n";
>
> How do you think this will interact with the previous line?
>
>> print "<img src=\"/images/angry.gif\">";
>
> You told it that the content type was an image/gif, but now you are sending
> it html, which is not image/gif.
>
>> When I try opening up test.cgi, I don't get ANY IMAGE outputted to my
>> browser.
>
> So, what *do* you see? A broken image icon? A 500 error?
>
> Xho
>

For your last question: I get broken image (no image, question mark box
in safari). No 500s.

thx

wrote:
> secSwami <> wrote:
>> I am messing around with cgi and perl. I have a cgi page test.cgi with
>> following code:
>>
>> #!/usr/bin/perl
>>
>> print "<html>
>> <head>
>> <title>TEST CAPTCHA IMAGE Verification</title>
>> </head>
>>
>> <body>
>> <img src=\"/cgi-bin/test3.cgi\">
>> </body>
>> </html>";
>
> You aren't printing a response header. That might be a problem. Then
> again, it might not.
>
> More importantly, you aren't using "use strict" and "use warnings", which
> will catch many errors for you. The first thing you should do is ask Perl
> to help you, by including use strict and use warnings.
>
>
>> As you can see I am calling test3.cgi as my image. Here is my code in
>> test3.cgi :
>>
>> #!/usr/bin/perl
>> use CGI;
>>
>> print header;
>
> What do you expect this to do? Are you sure it is doing it?
>
>> print "Content-type: image/gif\n\n";
>
> How do you think this will interact with the previous line?
>
>> print "<img src=\"/images/angry.gif\">";
>
> You told it that the content type was an image/gif, but now you are sending
> it html, which is not image/gif.
>
>> When I try opening up test.cgi, I don't get ANY IMAGE outputted to my
>> browser.
>
> So, what *do* you see? A broken image icon? A 500 error?
>
> Xho
>

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!