Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm doing some stuff with Facebooks FQL at the moment, and I'm using curl on the command line to test some of the responses of it. I'm also using export to keep the params seperated for easy editing. But I'm doing something wrong, and I can't see what.

This produces a perfectly fine result (even with the export):

export FB_TOKEN="the_access_token"
curl -F access_token=$FB_TOKEN -F query="SELECT first_name FROM user WHERE uid=12345678910123" https://api.facebook.com/method/fql.query

But this does mess up:

export FB_TOKEN="the_access_token"
export FB_QUERY="SELECT first_name FROM user WHERE uid=12345678910123"
curl -F access_token=$FB_TOKEN -F query=$FB_QUERY https://api.facebook.com/method/fql.query

and produces the following output:

curl: (6) Couldn't resolve host 'first_name'
curl: (6) Couldn't resolve host 'FROM'
curl: (6) Couldn't resolve host 'user'
curl: (6) Couldn't resolve host 'WHERE'
curl: (6) Couldn't resolve host 'uid=100001273321556'
<?xml version="1.0" encoding="UTF-8"?>
(...further response that the request was invalid here...)

I don't see anything I forgot to escape. Why does curl insist on interpreting these as hosts?

Used software versions:
curl 7.21.3; bash 4.2.8(1)

share|improve this question
up vote 2 down vote accepted

FB_QUERY must be quoted:

curl -F access_token=$FB_TOKEN -F query="$FB_QUERY" https://api.facebook.com/method/fql.query
share|improve this answer
Damn. I thank you for my facepalm of the day. =) – alextsc Sep 30 '11 at 13:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.