?
Solved

Close the php socket

Posted on 2001-07-16
4
Medium Priority
?
612 Views
Last Modified: 2012-06-27
I have php script that when invoked by the user may take minutes to run, and upon completion will upload a file to a server. However, i would prefer to not lockup the users browser connection after they press submit.

So, is there anyway to close the socket between apache and and the remote user but keep my script executing?

Jon Hess
0
Comment
Question by:theravada_maha
[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
  • 2
4 Comments
 
LVL 2

Expert Comment

by:curri
ID: 6288028
You can use system/exec to execute another program (which may be another php script). You can make programs execute on the background, so with a little script magic you can make it work. Also, if you redirect the output to another file, exec would NOT wait for the program to finish before returning. So you can do something like this:

- Write the rest of the process (ending with the upload :) into another php script (you can pass it info with parameters or something)

and then use a line like this in your main script:
exec("php rest_of_task.php > deleteme.txt");

Of course the problem is then that you have no way of sending any output/error messages from this process to the web browser (but you can send e-mails or something)

Orlando

0
 
LVL 2

Accepted Solution

by:
curri earned 150 total points
ID: 6288036
Also check this other question:
http://www.experts-exchange.com/jsp/qShow.jsp?ta=php&qid=20149480

They talk about the same thing in a different context (and their explanations probably do more sense than my previous comment :)
0
 
LVL 8

Expert Comment

by:us111
ID: 6288771
install php as cgi-bin, write your php script

exec("myscript.php&");
or exec ("myscript.php >/dev/null");
or if it doesn't work exec("myscript.php > /dev/null &");
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6419270
It's time to clean up this topic area and that means taking care of this question. Your options at this point are:

1. Award points to the Expert who provided an answer, or who helped you most. Do this by clicking on the "Accept Comment as Answer" button that lies above and to the right of the appropriate expert's name.

2. PAQ the question because the information might be useful to others, but was not useful to you. To use this option, you must state why the question is no longer useful to you, and the experts need to let me know if they feel that you're being unfair.

3.  Ask Community Support to help split points between participating experts.  Just comment here with details.

4.  Delete the question because it is of no value to you or to anyone else.  To use this option, you must state why the question is no longer useful to you, and the experts need to let me know if they feel that you're being unfair.

If you elect for option 2, 3 or 4, just post comment with details here and I'll take it from there.  We also request that you review any other open questions you might have and update/close them.  Display all your question history from your Member Profile to view details.

PLEASE DO NOT AWARD THE POINTS TO ME.

____________________________________________



Hi Experts:

In the event that the Asker does not respond, I would very much appreciate your opinions as to which Expert ought to receive points (if any) as a result of this question.  Likewise, you can also suggest that I PAQ or delete the question.

Experts, please do not add further "answer" information to this question.  I will be back in about one week to finalize this question.

Thank you everyone.

Moondancer :)
Community Support Moderator @ Experts Exchange

P.S.  REGARDING POINTS, Guidelines and more:  http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp  
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
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…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Suggested Courses

801 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