【问题标题】:Output from console commands run thru php get cutted通过 php 运行的控制台命令的输出被截断
【发布时间】:2011-11-20 01:06:48
【问题描述】:

当我通过 putty 在控制台中运行ps ax 命令时,我得到:

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 的所有字符都被截断?

【问题讨论】:

    标签: php console


    【解决方案1】:

    这是我们在脚本中使用的技术:

    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. 
    

    【讨论】:

      猜你喜欢
      • 2019-11-30
      • 1970-01-01
      • 1970-01-01
      • 2015-11-26
      • 2013-10-12
      • 2018-07-01
      • 2017-01-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多