php-general Digest 27 Jun 2011 15:01:17 -0000 Issue 7378

Topics (messages 313742 through 313754):

Re: asynchronous launch of a script
        313742 by: Jim Giner
        313743 by: Jim Lucas
        313744 by: Tamara Temple
        313746 by: Stuart Dallas
        313749 by: Richard Quadling

Re: Php filter validate url
        313745 by: Tim Streater
        313754 by: Plamen Ivanov

Re: [PHP-DB] Re: radio form submission
        313747 by: Richard Quadling
        313748 by: Steve Staples
        313751 by: Tim Streater

Re: Memory limit Problem
        313750 by: Graham Drabble
        313752 by: Lester Caine
        313753 by: Richard Quadling

Administrivia:

To subscribe to the digest, e-mail:
        [email protected]

To unsubscribe from the digest, e-mail:
        [email protected]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
You mean - you want a second thread to run independently of your current 
"running" script?  A wonderful thing to do and helpful for long intenesive 
processes but do you really want to go thru the hassles of managing two 
processes?  Won't you have to verify the results of your offshoot and react 
to unexpected circumstances?  Otherwise, what are  you doing that would not 
require such complex management? 



--- End Message ---
--- Begin Message ---
On 6/26/2011 7:58 PM, Jim Giner wrote:
You mean - you want a second thread to run independently of your current
"running" script?  A wonderful thing to do and helpful for long intenesive
processes but do you really want to go thru the hassles of managing two
processes?  Won't you have to verify the results of your offshoot and react
to unexpected circumstances?  Otherwise, what are  you doing that would not
require such complex management?


Having an OpenBSD server I use a thing called nohup.

I have a shell script that starts/stops things for me

nohup /usr/bin/ssh -2 -N -f -L $L_IP:$L_PORT:$R_IP:$R_PORT root@localhost 1>/dev/null

This starts a ssh tunnel port forwarding for me with a from and to port assignment.

But, one crucial thing you haven't told us is what OS you are trying to do this on.

Jim

--- End Message ---
--- Begin Message ---

On Jun 26, 2011, at 11:52 PM, Jim Lucas wrote:

On 6/26/2011 7:58 PM, Jim Giner wrote:
You mean - you want a second thread to run independently of your current "running" script? A wonderful thing to do and helpful for long intenesive processes but do you really want to go thru the hassles of managing two processes? Won't you have to verify the results of your offshoot and react to unexpected circumstances? Otherwise, what are you doing that would not
require such complex management?


Having an OpenBSD server I use a thing called nohup.

I have a shell script that starts/stops things for me

nohup /usr/bin/ssh -2 -N -f -L $L_IP:$L_PORT:$R_IP:$R_PORT root@localhost 1>/dev/null

This starts a ssh tunnel port forwarding for me with a from and to port assignment.

But, one crucial thing you haven't told us is what OS you are trying to do this on.

Jim

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


Wow, that's really getting complex. All I want is for a php script to get launched and the calling script to return immediately. I don't necessarily have to know or care when the called script ends, just want the user to get an immediate return instead of waiting around for the lengthy script to run. I'm not talking AJAX or anything like that where the page depends on the eventual output from the called script.



--- End Message ---
--- Begin Message ---
On Monday, 27 June 2011 at 07:10, Tamara Temple wrote:
> 
> On Jun 26, 2011, at 11:52 PM, Jim Lucas wrote:
> 
> > On 6/26/2011 7:58 PM, Jim Giner wrote:
> > > You mean - you want a second thread to run independently of your 
> > > current
> > > "running" script? A wonderful thing to do and helpful for long 
> > > intenesive
> > > processes but do you really want to go thru the hassles of managing 
> > > two
> > > processes? Won't you have to verify the results of your offshoot 
> > > and react
> > > to unexpected circumstances? Otherwise, what are you doing that 
> > > would not
> > > require such complex management?
> > 
> > Having an OpenBSD server I use a thing called nohup.
> > 
> > I have a shell script that starts/stops things for me
> > 
> > nohup /usr/bin/ssh -2 -N -f -L $L_IP:$L_PORT:$R_IP:$R_PORT 
> > root@localhost 1>/dev/null
> > 
> > This starts a ssh tunnel port forwarding for me with a from and to 
> > port assignment.
> > 
> > But, one crucial thing you haven't told us is what OS you are trying 
> > to do this on.
> Wow, that's really getting complex. All I want is for a php script to 
> get launched and the calling script to return immediately. I don't 
> necessarily have to know or care when the called script ends, just 
> want the user to get an immediate return instead of waiting around for 
> the lengthy script to run. I'm not talking AJAX or anything like that 
> where the page depends on the eventual output from the called script.

In my experience it's best to separate the processes and pass jobs to be done 
via a database, IPC, socket or other mechanism from the HTTP handler to the 
offline process. I use a job queueing system to accomplish this in most of my 
projects, where I can either schedule a repeating job or queue one-off jobs 
when needed. I wrote a post on my blog a little while ago describing that 
system...

http://stut.net/2009/05/29/php-job-queue/

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/


--- End Message ---
--- Begin Message ---
On 27 June 2011 03:42, Tamara Temple <[email protected]> wrote:
> How do I launch a php script from another running php script asynchronously?

I'm a windows user. One of the things I wanted to to was to create
non-blocking process which I could communicate with using PHP.

I use pecl/wincache to allow me to read/write data (can't use the
pipes as these are blocking and no support for non-blocking).
I also use ...

$WshShell = new COM("WScript.Shell");
$oExec = $WshShell->Run(...);

To create a new instance of a non blocking PHP script.

By using ...

$appID = ini_get('wincache.setappid');

I can supply do something like this ...

$s_Task = "C:\\PHP5\\php.exe -d wincache.setappid={$appID} -f " ....

to set the appid for the new instance, so it can communicate with this
instance via wincache.

All because there is no IPC in php for windows natively.

And it works for me really well.

I use pecl/win32service to create slow/long running tasks which have a
task controller controlling the work load.

I think I've re-invented a form of gearman in this work, but it works for me.


If you are on Windows and just want to get a script to run and really
don't care about when/how it ends, then

$WshShell = new COM("WScript.Shell");
$WshShell->Run("C:\\PHP5\\php-win.exe -f C:\\Scripts\\script.php", 0, false);

This will create an invisible non-blocking "thread" and return
immediately upon creating the "thread".


-- 
Richard Quadling
Twitter : EE : Zend : PHPDoc
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea

--- End Message ---
--- Begin Message ---
On 27 Jun 2011 at 00:15, Richard Riley <[email protected]> wrote: 

> In addition your content type in your post is incorrect.
>
> Your header contains
>
> Content-Type: multipart/alternative;
> boundary=00151747b53cf2927204a6a46ebb
>
> But its not multipart. This happens a lot in this group and I dont
> experience it elsewhere so I dont know if its a "php programmer thing",
> an gmane artifact or something the mailing list does.

I couldn't see anything in RFC2046, section 5.1.4, to suggest that 
multipart/alternative *requires* that there be more than one part. And why does 
it matter, anyway?

--
Cheers  --  Tim

--- End Message ---
--- Begin Message ---
On Sun, Jun 26, 2011 at 5:44 PM, Shawn McKenzie <[email protected]> wrote:
>
> On 06/26/2011 12:31 PM, Adam Tong wrote:
> > Hi,
> >
> > I wanted tu use php filters for validation to avoid regular expresions.
> > Is it possible that FILTER_VALIDATE_URL only checks if the string has
> > http:// and do not check for the format domain.something?
> > ----
> > $url = 'http://wwwtestcom';
> > $url = filter_var($url,FILTER_VALIDATE_URL);
> > echo $url;
> > -----
> >
> > Or I am doing something wrong
> >
> > Thank you
>
> Unless I'm totally misunderstanding what you want (validate that a
> string starts with http://) try:
>
> if(strpos($url, 'http://') === 0) {
>   //starts with http://
> } esle {
>   // does not start with http://
> }
>
> --
> Thanks!
> -Shawn
> http://www.spidean.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

Another possible solution could be:

$ary = explode('://', $url);
if (1 >= count($ary)) {
    echo 'No schema specified!';
} else {
    // Schema specified.
    // $ary[0] is the protocol
    $allowed = array('http', 'https');
    if (FALSE == in_array($ary[0], $allowed) {
        // Protocol not valid!
        exit(1); // or return FALSE; whatever...
    }
    // $ary[1] is the uri, validate with filter_var().
}

Hope this helps.

--- End Message ---
--- Begin Message ---
On 25 June 2011 22:11, Tamara Temple <[email protected]> wrote:
> On Jun 24, 2011, at 1:35 PM, Richard Quadling wrote:
>>
>> On 24 June 2011 18:23, Tamara Temple <[email protected]> wrote:
>>>
>>> On Jun 24, 2011, at 10:28 AM, Richard Quadling wrote:
>>>>
>>>> On 24 June 2011 15:44, Vitalii Demianets <[email protected]>
>>>> wrote:
>>>>>
>>>>> And furthermore, I think Carthage must be destroyed.
>>>
>>> Let's haul out the PHP war wagons!
>>>>
>>>> http://xkcd.com/327/
>>>
>>> I so wanted to rename my daughter "Little Chelsea Tables" after I read
>>> that one. Randall is one mean mofo.
>>
>> And because it is so relevant, I added it to the docs...
>>
>> http://docs.php.net/manual/en/security.database.sql-injection.php
>
> Well played, sir, well played. I think we should go through all the xkcd
> comics that relate to programming somehow and insert them in the php.net
> documentation :)

If you find them, ...

-- 
Richard Quadling
Twitter : EE : Zend : PHPDoc
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea

--- End Message ---
--- Begin Message ---
On Sat, 2011-06-25 at 16:11 -0500, Tamara Temple wrote:
> On Jun 24, 2011, at 1:35 PM, Richard Quadling wrote:
> > On 24 June 2011 18:23, Tamara Temple <[email protected]> wrote:
> >> On Jun 24, 2011, at 10:28 AM, Richard Quadling wrote:
> >>> On 24 June 2011 15:44, Vitalii Demianets <[email protected]>  
> >>> wrote:
> >>>> And furthermore, I think Carthage must be destroyed.
> >> Let's haul out the PHP war wagons!
> >>> http://xkcd.com/327/
> >> I so wanted to rename my daughter "Little Chelsea Tables" after I  
> >> read that one. Randall is one mean mofo.
> >
> > And because it is so relevant, I added it to the docs...
> >
> > http://docs.php.net/manual/en/security.database.sql-injection.php
> 
> Well played, sir, well played. I think we should go through all the  
> xkcd comics that relate to programming somehow and insert them in the  
> php.net documentation :)
> 
> 
Tamara, kind of like this one?

http://ca3.php.net/manual/en/control-structures.goto.php

I love that comic :)

Steve.


--- End Message ---
--- Begin Message ---
On 27 Jun 2011 at 13:18, Steve Staples <[email protected]> wrote: 

> On Sat, 2011-06-25 at 16:11 -0500, Tamara Temple wrote:

>> Well played, sir, well played. I think we should go through all the
>> xkcd comics that relate to programming somehow and insert them in the
>> php.net documentation :)
>>
>>
> Tamara, kind of like this one?
>
> http://ca3.php.net/manual/en/control-structures.goto.php

I haven't used a goto since I stopped writing FORTRAN in 1978.

--
Cheers  --  Tim

--- End Message ---
--- Begin Message ---
On 23 Jun 2011 [email protected] (Graham Drabble) wrote in 
news:[email protected]:

> On 23 Jun 2011 [email protected] wrote in
> news:[email protected]: 
> 
>> 
>> Check the value of the upload_max_filesize and post_max_size
>> directives in the php.ini. 
> 
> From phpinfo()
> 
> upload_max_filesize 800M 800M 
> post_max_size 1000M 1000M 
> 
> (fwiw the file I'm uploading is ~85MB)

Any ideas from anyone?

FWIW, the setup works on another server but doesn't work on this 
server. The upload_max_filesize, post_max_size and memory_limit are the 
same on both servers.

Both are PHP Version 5.2.6-1+lenny9 

-- 
Graham Drabble
http://www.drabble.me.uk/

--- End Message ---
--- Begin Message ---
Graham Drabble wrote:
 From phpinfo()
>
>  upload_max_filesize 800M 800M
>  post_max_size 1000M 1000M
>
>  (fwiw the file I'm uploading is ~85MB)
Any ideas from anyone?

FWIW, the setup works on another server but doesn't work on this
server. The upload_max_filesize, post_max_size and memory_limit are the
same on both servers.

Both are PHP Version 5.2.6-1+lenny9

Memory the same size on both machines? The error message you gave was certainly one of being 'out of resources' rather than hitting the file size limits ...

--
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk//
Firebird - http://www.firebirdsql.org/index.php

--- End Message ---
--- Begin Message ---
On 27 June 2011 14:16, Graham Drabble <[email protected]> wrote:
> On 23 Jun 2011 [email protected] (Graham Drabble) wrote in
> news:[email protected]:
>
>> On 23 Jun 2011 [email protected] wrote in
>> news:[email protected]:
>>
>>>
>>> Check the value of the upload_max_filesize and post_max_size
>>> directives in the php.ini.
>>
>> From phpinfo()
>>
>> upload_max_filesize 800M 800M
>> post_max_size 1000M 1000M
>>
>> (fwiw the file I'm uploading is ~85MB)
>
> Any ideas from anyone?
>
> FWIW, the setup works on another server but doesn't work on this
> server. The upload_max_filesize, post_max_size and memory_limit are the
> same on both servers.
>
> Both are PHP Version 5.2.6-1+lenny9

I'd check for other differences in the phpinfo() output.

Anything that is different should be examined and verified as being appropriate.

-- 
Richard Quadling
Twitter : EE : Zend : PHPDoc
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY : bit.ly/lFnVea

--- End Message ---

Reply via email to