2011-09-19 52 views
1

當我通過膩子運行控制檯ps ax命令我得到:輸出Get板缺

1053 ?? Ss  0:45.47 /usr/local/sbin/nrpe2 -d -c /usr/local/etc/nrpe.cfg 
1085 ?? Is  0:00.03 /bin/sh /usr/local/bin/mysqld_safe --defaults-extra-file=/var/db/mysql/my.cnf --user=mysql --datadir=/var/db/mysql --pid-file=/var/db/mysql/MYNAME.pid 

但是當我通過PHP運行此命令:

exec('ps ax', $o); 
print_r($o); 

我得到的相同,但切割

[27] => 1053 ?? Ss  0:45.48 /usr/local/sbin/nrpe2 -d -c /usr/local/etc/nrpe.cfg 
[28] => 1085 ?? Is  0:00.03 /bin/sh /usr/local/bin/mysqld_safe --defaults-extra-f 

爲什麼位置> = 79的所有字符都被截斷了?

回答

2

下面是我們對我們的腳本中使用的技術:

exec("export COLUMNS=1000; ps ax | grep $parameter", $results); 

Here's what COLUMNS means

COLUMNS 
    Used by the select builtin command to determine the terminal width when 
    printing selection lists. Automatically set upon receipt of a SIGWINCH. 
+0

TNX隊友,它的工作原理! –