Hello all,
Here is proof that my site is not portable. I had some regex that worked perfectly on my old server. I have now transferred my site to a new server and it doesn't work.
$handle = popen('/usr/bin/python '.YOUTUBEDL.'youtube-dl.py -o '.VIDEOPATH.$fileName.'.flv '.$url.' 2>&1', 'rb');
while(!feof($handle))
{
$progress = fread($handle, 8192);
$pattern = '/(?<percent>[0-9]{1,3}\.[0-9]{1,2})% of (?<filesize>.+) at/';
///######Does not execute this if - no matches
if(preg_match_all($pattern, $progress, $matches)){
fwrite($fh, $matches[0][0]."\r\n");
}
}
The output of the from the shell is something like this and the regex should match filesize and percentage.
[download] 56.8% of 4.40M at 142.40k/s ETA 00:13
The regex worked on the previous server but not this one. Why? How can I debug this?
The difference in the servers is that the previous one was Fedora and its now Centos. Also I specified the shell as /bin/bash.
Is there anything in the PHP.ini that could cause a change in this?
Please help.
Update
The output of $progress is this: (just a small sample)
[download] 87.1% of 4.40M at 107.90k/s ETA 00:05
[download] 89.0% of 4.40M at 107.88k/s ETA 00:04
[download] 91.4% of 4.40M at 106.09k/s ETA 00:03
[download] 92.9% of 4.40M at 105.55k/s ETA 00:03
Update 2
Could that regex fail because of extra spacing in the output?
Also would a different shell make a difference??
[SOLVED]
This was solved and it was due to the regex requiring a P - see here for more details: http://stackoverflow.com/questions/669178/does-this-regex-in-php-actually-work