Solved

Stopping CGI/Perl  when Browser stops listening

Posted on 1998-07-24
1
201 Views
Last Modified: 2013-12-25
I have made a CGI-Perl script which feeds back multple JPG images to a <IMG> tag client call.  The multi images can run up to 200 JPGs.  One thing that's for sure is the client won't sit there for all 200 JPGS to show on their screen as an animation (they'll leave my page to somewhere else).  Now if this is the case, I'd hate for my CGI script to "keep sending" JPG images if there's no one watching it.

Therefore, I'd like to have my Perl script "immediately" stop sending images and quit if the client browser has stopped accepting images.  I remeber such a command exists in Perl but I totally forget what it is.  Would you know the answer?

Thanks.
0
Comment
Question by:ljaques
1 Comment
 
LVL 6

Accepted Solution

by:
alamo earned 0 total points
ID: 1831149
You probably have a line to copy the image file to STDOUT which looks something like:
print <IN>;

Change it to:
print (<IN>) || last;

When the user hits stop on the browser, the server kills STDOUT and thus print fails. (Bet you didn't know print was a function that returns true or false, most people don't use it that way). What you are going to print needs to be enclised in () so that it doesn't try to print <IN>||last, which won't work.

Hope this helps!

p.s. I would have told you this last time if I had realized it, I knew it was possible but had never actually figured out how to do it. Now I have :-)
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
The viewer will learn how to dynamically set the form action using jQuery.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now