Solved

Stopping CGI/Perl  when Browser stops listening

Posted on 1998-07-24
1
206 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This tutorial will give you a fast look what you can do with WhizBase. I expect you already know how to work with HTML at least, and that you understand the basics of the internet and how the internet works. WhizBase is a server-s…
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

756 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