cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: cURL command works in command line but not in php exec()

From: Dan Fandrich <dan_at_coneharvesters.com>
Date: Sat, 23 Aug 2008 12:01:56 -0700

On Sat, Aug 23, 2008 at 06:47:45PM +0100, Rob Mills wrote:
> I'm having a problem that a cURL command works in command line but not in
> php exec(), this is the command:
>
> curl -u user:pass -T /home/ftpuser/public_html/test
> sftp://127.0.0.1/Usr/remoteuser/
>
> That works but when run in php like this:
>
> exec("curl -u user:pass -T /home/ftpuser/public_html/test
> sftp://127.0.0.1/Usr/remoteuser/");
>
> it doesnt work and the following error appears in the logs:
>
> curl: (1) Unsupported protocol: sftp

That means that the curl you're using from the command line is different from
the curl used from PHP. You may have /usr/local/bin in your personal PATH
whereas PHP's PATH doesn't, for example. Try running 'which curl' from
the command line and use that path directly in PHP.

> I added a "--trace" to the command and got this in the logs:
>
> == Info: gethostbyname_r(2) failed for user:pass
> == Info: Couldn't resolve host 'user:pass'
> == Info: Closing connection #0
> curl: (6) Couldn't resolve host 'user:pass'
> == Info: Unsupported protocol: sftp
> curl: (1) Unsupported protocol: sftp

You obviously added a --trace without giving a file name, which makes curl
use -u as the file name which makes it think the user:pass is the URL.

>>> Dan

> By the way, i know i should really be doing this with the SSH2 library
> but i am not able to install it on the server.

If your command line curl works with sftp already, then you already have
the library installed.

>>> Dan

-- 
http://www.MoveAnnouncer.com              The web change of address service
          Let webmasters know that your web site has moved
-------------------------------------------------------------------
List admin: http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-users
FAQ:        http://curl.haxx.se/docs/faq.html
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2008-08-23