[PHP] Execute script and redirect

2006-04-20 Thread Peter Lauri
Best groupmember,

 

I have a form that is being filled out. This is the process:

 

1.  Fill out form and click submit
2.  Script validates data
3.  Data is being sent to external source via Web Service
4.  A file is being downloaded (redirects to files location)

 

The problem is that #3 is taking around 15 seconds to complete because the
Web Service is very slow. I would like to run #3 in the background and
directly jump to #4.

 

Is this possible?

 

A little confused :)

 

/Peter

 

 

 

 



Re: [PHP] Execute script and redirect

2006-04-20 Thread Richard Lynch
On Thu, April 20, 2006 2:23 am, Peter Lauri wrote:
 1.Fill out form and click submit
 2.Script validates data
 3.Data is being sent to external source via Web Service
 4.A file is being downloaded (redirects to files location)

 The problem is that #3 is taking around 15 seconds to complete because
 the
 Web Service is very slow. I would like to run #3 in the background and
 directly jump to #4.

 Is this possible?

There's possible, and then there's possible...

How about this:

The BEST solution would be to insert the [valid/clean] data into a
database, and run a cron job to send off everything to the Web
Service.

You'll have to mark what's sent and what isn't and be careful not to
run two jobs at once when it's really slow (sending duplicate data)
nor to skip data that didn't safely get sent.

But should do all that anyway in your script.

There might even be functions in the Web Service to make it easy for
you to send a whole BUNCH of records at once, saving a lot of time on
your end.

And, for sure, if all your script has to do is insert to a database
table for step 3, it's gonna be pretty fast.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Execute script and redirect

2006-04-20 Thread Peter Lauri
That was a smart solution. However, my client have not given me access to
the MySQL database at this stage (just doing a small side project of the
clients web site). If you could not take advantage of database and cron job,
what would you do?

PS! I am not sure that my clients host supports cron jobs  DS!



-Original Message-
From: Richard Lynch [mailto:[EMAIL PROTECTED] 
Sent: Thursday, April 20, 2006 2:57 PM
To: Peter Lauri
Cc: php-general@lists.php.net
Subject: Re: [PHP] Execute script and redirect

On Thu, April 20, 2006 2:23 am, Peter Lauri wrote:
 1.Fill out form and click submit
 2.Script validates data
 3.Data is being sent to external source via Web Service
 4.A file is being downloaded (redirects to files location)

 The problem is that #3 is taking around 15 seconds to complete because
 the
 Web Service is very slow. I would like to run #3 in the background and
 directly jump to #4.

 Is this possible?

There's possible, and then there's possible...

How about this:

The BEST solution would be to insert the [valid/clean] data into a
database, and run a cron job to send off everything to the Web
Service.

You'll have to mark what's sent and what isn't and be careful not to
run two jobs at once when it's really slow (sending duplicate data)
nor to skip data that didn't safely get sent.

But should do all that anyway in your script.

There might even be functions in the Web Service to make it easy for
you to send a whole BUNCH of records at once, saving a lot of time on
your end.

And, for sure, if all your script has to do is insert to a database
table for step 3, it's gonna be pretty fast.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Execute script and redirect

2006-04-20 Thread Richard Lynch
On Thu, April 20, 2006 3:42 am, Peter Lauri wrote:
 That was a smart solution. However, my client have not given me access
 to
 the MySQL database at this stage (just doing a small side project of
 the
 clients web site). If you could not take advantage of database and
 cron job,
 what would you do?

 PS! I am not sure that my clients host supports cron jobs  DS!

At that point, I go to the client and explain why I need cron jobs and
database access.

We then either go to the host and get it.

Or we find a host that will provide it.

Or, in extreme cases, I build that side portion of their site on a
good host, and provide some kind of API (however crude it may be) so
that the functionality appears on their website, even when it's not
really on their host.

Attempting to fork from exec is an exercise in frustration and
version-specific gotchas as well as more than a few generalized
gotchas

I've done it, and it is possible but it's such a Last Resort, that I
wouldn't recommend it.

In principle, it's as easy as:
?php
  $command = send junk off to Web Services shell script $args;
  exec($command , $output, $error);
  //This next line is a shameless plug for http://l-i-e.com/perror
  if (function_exists('strerror')) $error .=   . strerror($error);
  if ($error) error_log(OS Error: $error - $command);
?

In practice, depending on the setup of the server and a whole host of
conditions I never quite understood, the  will or won't work.

You can maybe fix that with a shell script of your own that does the 
but if you don't have shell access, that's pretty much not fun with
FTP and test/re-test.

Then...  I could go on a lot longer, but am going to quit now.

You could do without the database by just appending the info into a
flat file...

You can find work-arounds to the cron problem in many ways -- Sites
that surf to your page in a cron-like fashion, running cron elsewhere
to hit your own page, etc...

I'd go with any of those before trying to fork in a web environment,
personally.

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php