dongyanling9248 2009-06-18 07:12
浏览 80
已采纳

PHP:将多行命令行输出输出为不同的行

PHP: Output multiple line command-line outputs as different lines. Sorry if the title is difficult to understand. Basically I want my output like A, instead of B. It currently looks like B. I have tried nl2br. The script I am trying to run is:

Script:

echo "Virus Scan Results:";
$scanme = system('cd /var/www/upload/files; clamscan --remove=yes '.$furl);
printf(nl2br($scanme));

A:

802931t_e_s_t.txt: OK 
----------- SCAN SUMMARY ----------- 
Known viruses: 574585 
Engine version: 0.95.1 
Scanned directories: 0 
Scanned files: 1 
Infected files: 0 
Data scanned: 0.00 MB 
Data read: 0.00 MB (ratio 0.00:1) 
Time: 2.352 sec (0 m 2 s) 
Time: 2.352 sec (0 m 2 s)

B:

802931t_e_s_t.txt: OK ----------- SCAN SUMMARY ----------- Known viruses: 574585 Engine version: 0.95.1 Scanned directories: 0 Scanned files: 1 Infected files: 0 Data scanned: 0.00 MB Data read: 0.00 MB (ratio 0.00:1) Time: 2.352 sec (0 m 2 s) Time: 2.352 sec (0 m 2 s)
  • 写回答

3条回答 默认 最新

  • doulan6150 2009-06-18 07:14
    关注

    why are you using nl2br if this is on the command line?

    nl2br outputs <br /> tags for new lines... which would have no meaning on command line

    Edit

    Two things:

    1 try

    system('cd /var/www/upload/files; clamscan --remove=yes '.$furl, $scanme);
    

    2 You may want to use the exec function instead of system

    e.g.

    exec('cd /var/www/upload/files; clamscan --remove=yes '.$furl, $scanme);
    $scanme = implode("
    ",$scanme);
    

    exec ( string $command [, array &$output [, int &$return_var ]] )

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

报告相同问题?

悬赏问题

  • ¥30 Unity接入微信SDK 无法开启摄像头
  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源