PHP execution mongoexport using exec execution

Source: Internet
Author: User

EXEC (' mongoexport-h 192.168.6.97--port 40000-d fenjianlidb-c fenjianli-f ' meta_info.file_path '-Q ' {\ ' create_time\ ': {\ ' $gte \ ': \ ' 1487088000\ ', \ ' $lte \ ': \ ' 1487644200\ '}} '-O '. $save _path. '  Middle.txt ', $ret); Window Platform


PHP execution

EXEC (' mongoexport-h 192.168.6.97--port 40000-d zhengliangdb-c newzengliang-f ' Meta_info.file_path "-q \ ' {create_time: {$gte: 1487645408, $lte: 1487646251}}  \ '-o/data/work_time/work0221/testmid/middle.txt ', $ret); Linux success (remember transfer) Mongoexport--help view

--------------------------------------Test Code-----------------------------------------

<?php

/**

* @Author: Lixiaozhu

* @Date: 2016-09-21 12:51:55

* @Last Modified By:lixiaozhu

* @Last Modified time:2017-01-20 18:50:24

*/

Set_time_limit (0);

$save _path = ' d:/phpstudy/www/test01/mongo/test0221/';

$save _path = '/data/work_time/work0221/testmid/';

Middleware

EXEC (' mongoexport-h 192.168.6.97--port 40000-d fenjianlidb-c fenjianli-f ' meta_info.file_path '-Q ' {\ ' create_time\ ': {\ ' $gte \ ': \ ' 1487088000\ ', \ ' $lte \ ': \ ' 1487644200\ '}} '-O '. $save _path. '  Middle.txt ', $ret); Window Platform


PHP execution

EXEC (' mongoexport-h 192.168.6.97--port 40000-d zhengliangdb-c newzengliang-f ' Meta_info.file_path "-q \ ' {create_time: {$gte: 1487645408, $lte: 1487646251}}  \ '-o/data/work_time/work0221/testmid/middle.txt ', $ret); Linux success



$groups = Array (

' group1 ' = ' http://192.168.6.49/',

' group2 ' = ' http://192.168.6.50/',

);


$content = file_get_contents ($save _path. ' Middle.txt ');


$list = Preg_split ('/\s+/', $content);

$prefix = Date (' YMDH ');

foreach ($list as $key = = $item) {

Echo $key + +, Php_eol;

$item = Json_decode ($item, true);

$file _path = Trim ($item [' meta_info '] [' file_path ']);

$group = substr ($file _path, 0, 6);

if (Isset ($groups [$group])) {

$url = $groups [$group]. $file _path;

$content = file_get_contents ($url);

if (False!== Strpos ($content, ' zhaopin.com ')) {//There may be zhaopin.cn localhost/qiaoda/zhilian/z1.html

Error_log ($url. Php_eol, 3, $save _path. $prefix. ' _zhilian.txt ');

} elseif (False!== Strpos ($content, ' 51job.com ')) {

Error_log ($url. Php_eol, 3, $save _path. $prefix. ' _51job.txt ');

} elseif (False!== Strpos ($content, ' liepin.com ')) {

Error_log ($url. Php_eol, 3, $save _path. $prefix. ' _liepin.txt ');

} elseif (False!== Strpos ($content, ' ganji.com ')) {

Error_log ($url. Php_eol, 3, $save _path. $prefix. ' _ganji.txt ');

} elseif (False!== Strpos ($content, ' 58.com ')) {

Error_log ($url. Php_eol, 3, $save _path. $prefix. ' _58tongchen.txt ');

} elseif (False!== Strpos ($content, ' chinahr.com ')) {

Error_log ($url. Php_eol, 3, $save _path. $prefix. ' _ycjianli.txt ');

} else {

Error_log ($url. Php_eol, 3, $save _path. $prefix. ' _other.txt ');

}

} else {

Echo ' Mubanfileerror ';

Error_log ($file _path. Php_eol, 3, $save _path. $prefix. ' _mubanfileerror.txt ');

}

Unset ($content);

}


This article is from the "JSON in PHP usage" blog, so be sure to keep this source http://zhaozhangxiao.blog.51cto.com/10609825/1899773

PHP execution mongoexport using exec execution

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.