doufeikuang7724 2013-04-13 19:41
浏览 33
已采纳

php系统函数提供异常输出

my php code

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

my browser displays

    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

and this is how the command actually displays this

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!

Question : so what is the problem with the system function, and where is the rest of the values coming from as i am expecting the web browser to echo as shown by my commnad, and how do I fix it

PS: note I ran the PHP page and the command a few seconds apart so the values are a little off

  • 写回答

2条回答 默认 最新

  • dousong2967 2013-04-13 19:47
    关注

    Those are ascii color codes, the service doesn't seem to detect if the calling terminal supports them or not. You can try to get rid of them with echo. You can try sed snippets like these.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向