Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cURL doesn't work from command line?

Tags:

php

curl

I wrote a script to parse some data from a website using cURL and it works fine when I run it in my browser, however when I want to run it in the command line I get the error "call to undefined function curl_init()". Do php scripts run under different settings from the command line?

like image 671
AFK Avatar asked Nov 14 '22 09:11

AFK


1 Answers

This is happening because you are simply trying to call a PHP function from bash. If you have curl installed in your linux environment then the command should simply be curl [-options] [url]. The simplest of them being something like:

$ curl http://someurl.com/path/to/xmlfile.xml

You can test for this from the command line by tying "$ which curl" (without the quotes of course). That will give you the path to where it is stored in case you have to use the full path. (e.g. /usr/bin/curl [-options] [url]).

EDIT: after having re-read your question I realized that I dumbly missed the fact that you said you were trying to run the PHP script from the command line and not curl itself. And now I, too, am stumped by your problem. Sorry!

like image 127
Yes Barry Avatar answered Dec 14 '22 22:12

Yes Barry