2011-09-19 37 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队友,它的工作原理! –