dpquu9206 2011-09-29 01:35 采纳率: 0%
浏览 334
已采纳

PHP上的shell_exec和exec没有返回字符串

I got headache by this code:

$data = shell_exec("wget -S --spider http://dkphp.com");
echo "Encoded:" .$data;

$data is "NULL"

I don't know why, its support to echo something like :( Spend like 5 hours today, and its still NULL :(

HTTP request sent, awaiting response...
  HTTP/1.0 200 OK
  Date: Thu, 29 Sep 2011 01:31:45 GMT
  Server: LiteSpeed
  Connection: close
  X-Powered-By: PHP/5.3.8
  Set-Cookie: PHPSESSID=50781d657c7632cc1b2e7536d5fa0c50; path=/
  Expires: Thu, 19 Nov 1981 08:52:00 GMT
  Cache-Control: no-store, no-cache, must-revalidate, post-check=0,
  Pragma: no-cache
  content: text/html
  Content-Type: text/html
Length: unspecified [text/html]
200 OK
  • 写回答

1条回答 默认 最新

  • douh9817 2011-09-29 01:40
    关注

    I checked your code snippet in PHP's interactive mode (php -a from the command line)

    wget prints that information to STDERR, not STDOUT.

    This works:

    $data = shell_exec("wget -S --spider http://dkphp.com 2>&1");
    echo "Encoded:" .$data;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 (标签-STM32|关键词-智能小车)
  • ¥20 关于#stm32#的问题,请各位专家解答!
  • ¥15 (标签-python)
  • ¥15 第一个已完成,求第二个做法
  • ¥20 搭建awx,试了很多版本都有错
  • ¥15 java corba的客户端该如何指定使用本地某个固定IP去连接服务端?
  • ¥15 activiti工作流问题,求解答
  • ¥15 有人写过RPA后台管理系统么?
  • ¥15 Bioage计算生物学年龄
  • ¥20 如何将FPGA Alveo U50恢复原来出厂设置哇?