Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/295.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
“产出”;linux shell“;vs";php系统()分类_Php_Linux_Output - Fatal编程技术网

“产出”;linux shell“;vs";php系统()分类

“产出”;linux shell“;vs";php系统()分类,php,linux,output,Php,Linux,Output,让我们执行以下命令: # zcat -f /var/log/remotelog*|grep -e "10\.0\.1\.15"|grep -e "7,35)"|sort -k 1M -k 2r|tail -n 250 3>&1 得到如下输出: Apr 3 11:38:49 10.0.1.15 GPOND[927]: ONU(7,35) eth port 1 link on(operational) Apr 3 11:38:35 10.0.1.15 GPOND[927]: ON

让我们执行以下命令:

# zcat -f /var/log/remotelog*|grep -e "10\.0\.1\.15"|grep -e "7,35)"|sort -k 1M -k 2r|tail -n 250 3>&1
得到如下输出:

Apr  3 11:38:49 10.0.1.15 GPOND[927]: ONU(7,35) eth port 1 link on(operational)
Apr  3 11:38:35 10.0.1.15 GPOND[927]: ONU(7,35) eth port 1 link off(operational)
Apr  3 11:06:20 10.0.1.15 GPOND[927]: ONU(7,35) eth port 1 link on(operational)
Apr  3 11:06:16 10.0.1.15 GPOND[927]: ONU(7,35) eth port 1 link off(operational)
Apr  3 11:06:15 10.0.1.15 GPOND[927]: ONU(7,35) eth port 1 link on(operational)
Apr  3 11:05:41 10.0.1.15 GPOND[927]: ONU(7,35) eth port 1 link off(operational)
Apr  2 17:54:02 10.0.1.15 GPOND[927]: ONU(7,35) eth port 1 link on(operational)
Apr  2 17:53:31 10.0.1.15 GPOND[927]: ONU(7,35) eth port 1 link off(operational)
Apr  1 02:02:27 10.0.1.15 GPOND[927]: Success upgrade ONU(7,35)
Apr  1 02:02:23 10.0.1.15 GPOND[927]: Success Download-OS ONU(7,35)
Mar 31 15:03:51 10.0.1.15 GPOND[927]: ONU(7,35) eth port 1 link on(operational)
Mar 31 15:03:41 10.0.1.15 GPOND[927]: ONU(7,35) eth port 1 link off(operational)
非常好

但我是这样做的:

<?php
$e = "zcat -f /var/log/remotelog*|grep -e \"10\.0\.1\.15\"|grep -e \"7,35)\"|sort -k 1M -k 2r|tail -n 250 3>&1";
system($e, $ret);
echo $ret ;
?>

为什么??我不明白…

如果我理解正确,第二个(通过PHP)是“正确”的输出


由于列表首先按月份名称排序,并且月份名称取决于区域设置,因此我怀疑区域设置(LC_*环境变量)在命令行和PHP中是不同的,这会影响排序的输出。

你说得对。现在看起来很明显-我在排序之前添加了env LC_ALL=pl_pl,现在它就像一个符咒。谢谢!
Mar 31 15:03:51 10.0.1.15 GPOND[927]: ONU(7,35) eth port 1 link on(operational)
Mar 31 15:03:41 10.0.1.15 GPOND[927]: ONU(7,35) eth port 1 link off(operational)
Apr  3 11:38:49 10.0.1.15 GPOND[927]: ONU(7,35) eth port 1 link on(operational)
Apr  3 11:38:35 10.0.1.15 GPOND[927]: ONU(7,35) eth port 1 link off(operational)
Apr  3 11:06:20 10.0.1.15 GPOND[927]: ONU(7,35) eth port 1 link on(operational)
Apr  3 11:06:16 10.0.1.15 GPOND[927]: ONU(7,35) eth port 1 link off(operational)
Apr  3 11:06:15 10.0.1.15 GPOND[927]: ONU(7,35) eth port 1 link on(operational)
Apr  3 11:05:41 10.0.1.15 GPOND[927]: ONU(7,35) eth port 1 link off(operational)
Apr  2 17:54:02 10.0.1.15 GPOND[927]: ONU(7,35) eth port 1 link on(operational)
Apr  2 17:53:31 10.0.1.15 GPOND[927]: ONU(7,35) eth port 1 link off(operational)
Apr  1 02:02:27 10.0.1.15 GPOND[927]: Success upgrade ONU(7,35)
Apr  1 02:02:23 10.0.1.15 GPOND[927]: Success Download-OS ONU(7,35)