php系统函数提供异常输出

时间:2013-04-13 19:41:20

标签: php command

我的PHP代码

$last_line = system('service airtime-media-monitor status');
echo $last_line;

我的浏览器显示

    AIRTIME_STATUS_URL             = [1;32mhttp://localhost:80/api/status/format/json/api_key/%%api_key%%[0m
AIRTIME_SERVER_RESPONDING      = [1;32mOK[0m
KERNEL_VERSION                 = [1;32m2.6.32-21-generic[0m
MACHINE_ARCHITECTURE           = [1;32mi686[0m
TOTAL_MEMORY_MBYTES            = [1;32m2051244[0m
TOTAL_SWAP_MBYTES              = [1;32mUNKNOWN[0m
AIRTIME_VERSION                = [1;32m2.3.1[0m
OS                             = [1;32mUbuntu 10.04 LTS i686[0m
CPU                            = [1;32mIntel(R) Core(TM)2 Duo CPU     E8400  @ 3.00GHz[0m
WEB_SERVER                     = [1;32mApache/2.2.14 (Ubuntu)[0m
PLAYOUT_ENGINE_PROCESS_ID      = [1;32m1195[0m
PLAYOUT_ENGINE_RUNNING_SECONDS = [1;32m121517[0m
PLAYOUT_ENGINE_MEM_PERC        = [1;32m0.5%[0m
PLAYOUT_ENGINE_CPU_PERC        = [1;32m0.4%[0m
LIQUIDSOAP_PROCESS_ID          = [1;32m4362[0m
LIQUIDSOAP_RUNNING_SECONDS     = [1;32m4564[0m
LIQUIDSOAP_MEM_PERC            = [1;32m0.7%[0m
LIQUIDSOAP_CPU_PERC            = [1;32m11.4%[0m
MEDIA_MONITOR_PROCESS_ID       = [1;32m1489[0m
MEDIA_MONITOR_RUNNING_SECONDS  = [1;32m121509[0m
MEDIA_MONITOR_MEM_PERC         = [1;32m0.5%[0m
MEDIA_MONITOR_CPU_PERC         = [1;32m0.0%[0m
-- Your installation of Airtime looks OK!
-- Your installation of Airtime looks OK!null

这就是命令实际显示的方式

AIRTIME_STATUS_URL             = http://localhost:80/api/status/format/json/api_key/%%api_key%%                                        
AIRTIME_SERVER_RESPONDING      = OK
KERNEL_VERSION                 = 2.6.32-21-generic
MACHINE_ARCHITECTURE           = i686
TOTAL_MEMORY_MBYTES            = 2051244
TOTAL_SWAP_MBYTES              = UNKNOWN
AIRTIME_VERSION                = 2.3.1
OS                             = Ubuntu 10.04 LTS i686
CPU                            = Intel(R) Core(TM)2 Duo CPU     E8400  @ 3.00GHz
WEB_SERVER                     = Apache/2.2.14 (Ubuntu)
PLAYOUT_ENGINE_PROCESS_ID      = 1195
PLAYOUT_ENGINE_RUNNING_SECONDS = 121187
PLAYOUT_ENGINE_MEM_PERC        = 0.5%
PLAYOUT_ENGINE_CPU_PERC        = 0.0%
LIQUIDSOAP_PROCESS_ID          = 4362
LIQUIDSOAP_RUNNING_SECONDS     = 4234
LIQUIDSOAP_MEM_PERC            = 0.7%
LIQUIDSOAP_CPU_PERC            = 11.4%
MEDIA_MONITOR_PROCESS_ID       = 1489
MEDIA_MONITOR_RUNNING_SECONDS  = 121179
MEDIA_MONITOR_MEM_PERC         = 0.5%
MEDIA_MONITOR_CPU_PERC         = 0.0%
-- Your installation of Airtime looks OK!

问题:那么系统功能有什么问题,其余的值来自哪里,因为我期望网络浏览器如我的commnad所示回应,以及如何修复它

PS:注意我运行PHP页面和命令几秒钟,所以值稍微偏离

2 个答案:

答案 0 :(得分:3)

那些是ascii color codesservice似乎没有检测到主叫终端是否支持它们。 您可以尝试使用echo 删除它们。您可以尝试sed snippets like these

答案 1 :(得分:1)

您的程序使用外壳颜色。 [1;32m由shell使用,但不是逐字输出。 请参阅:https://unix.stackexchange.com/questions/43408/printing-colored-text-using-echo