douhuireng4407 2009-07-31 02:30
浏览 301
已采纳

从PHP exec()调用时cURL失败

I'm making a call to download an XML file and write it to a file using exec() and the curl command. I tried using curl_exec(), but it wasn't recognized by my PHP system.

Somehow, the cURL call now fails. It didn't before, but one day I visit my site and– WHAM. Bye bye XML parser.

Things that did work:

  • Calling cURL from the command line with the same argument.
  • exec("ls /");

Things that didn't work:

  • which curl, then completing the path to the cURL in my exec function.
  • Googling the error that the curl throws when I output the errors from the exec function

    ld.so.1: curl: fatal: /opt/csw/lib/libsunmath.so.1: unknown file type

  • Using shell_exec

  • Using wget hung the script somehow. Just never finished.
  • Self-flagellation
  • 写回答

1条回答 默认 最新

  • douchen7555 2009-07-31 04:09
    关注

    I managed to code around the problem. I found out that the script was hanging with wget because a server wasn't responding. Bummer, but removing that link fixed my issue.

    It's sad because the way I was using cURL was much cleaner for IO. Fortunately this update checks input before changing files. This now creates a temporary file that wget downloads to and then checks to make sure it's the right format before moving the file to its new location.

    An ordeal, to be sure, but lots of good things to come of it.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?