It's not a curl problem. (The 22 error is just passing along the server-side HTTP 400 error, which is because it dumped an error message into a URL.) I think terdon is right and there's something wrong with your edirect installation. You have esearch and efetch on your PATH but apparently not xtract and/or xtract.Darwin.
More detail:
Look toward the end of the error message, at the text being passed to curl's -d
argument:
db=pubmed&id=Unable%2Cto%2Clocate%2Cxtract%2Cexecutable.%2CPlease%2Cexecute%2Cthe%2Cfollowing%2Cnquire%2Cdwn%2Cftp.ncbi.nlm.nih.gov%2Centrez%2Centrezdirect%2Cxtract.Darwin.gz%2Cgunzip%2Cf%2Cxtract.Darwin.gz%2Cchmod%2Cx%2Cxtract.Darwin&rettype=medline&retmode=text&tool=edirect&edirect=16.1&edirect_os=Darwin&email=mariocatalano%40MBP-di-Mario.lan"
It's putting this in the id=
part:
Unable%2Cto%2Clocate%2Cxtract%2Cexecutable.%2CPlease%2Cexecute%2Cthe%2Cfollowing%2Cnquire%2Cdwn%2Cftp.ncbi.nlm.nih.gov%2Centrez%2Centrezdirect%2Cxtract.Darwin.gz%2Cgunzip%2Cf%2Cxtract.Darwin.gz%2Cchmod%2Cx%2Cxtract.Darwin
which is maybe something like (trying to guess which characters got turned into %2C
):
Unable to locate xtract executable. Please execute the following: nquire -dwn ftp.ncbi.nlm.nih.gov entrez/entrezdirect xtract.Darwin.gz; gunzip -f xtract.Darwin.gz; chmod +x xtract.Darwin
But you should already have xtract and xtract.Darwin from the same edirect install that gave you esearch and efetch.
For what it's worth the official Entrez Direct install on Mac OS looks a little goofy. When I try it myself it ends with:
Entrez Direct has been successfully downloaded and installed.
-e In order to complete the configuration process, please execute the following:
echo "export PATH=\\\${PATH}:" >> $HOME/.bashrc
echo "export PATH=\\\${PATH}:" >> $HOME/.zshrc
or manually edit the PATH variable assignments in your .bashrc and .zshrc files.
Would you like to do that automatically now? [y/N]
Those commands don't look right (what's getting added to the path? an empty string?) and if I say y, I get this at the end of .bashrc and .zshrc which definitely isn't right:
export PATH=${PATH}:
It seems like an empty string at the end of PATH behaves like .
(current directory), so I can go into ~/edirect and run your command and it does actually work. So this isn't exactly your problem... but still, that seems wrong.