cURL & pdftotext

Dear Experts,

How can I send the output of curl to pdftotext?

I have tried

curl [url] | pdftotext - output.txt

But it does not work.

Please help.
Who is Participating?
Fabio MarzoccaConnect With a Mentor FreelancerCommented:
You should write a script, as the pipe doesnt wait for curl downloading completion. Save the file in /tmp, then pdftotext
It looks like pdftotext doesn't understand "-" as stdin. try this:

curl [url] | pdftotext /dev/stdin output.txt
narmi2Author Commented:
# curl works perfectly and downloads the file:

[narmi2@server]$ curl http://localhost/input.pdf -o output.pdf
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  327k  100  327k    0     0  4226k      0 --:--:-- --:--:-- --:--:-- 7609k

# however, when I try to pipe it, it all goes wrong:

[narmi2@server]$ curl http://localhost/input.pdf | pdftotext /dev/stdin output.txt
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  4  327k    4 16124    0     0   280k      0  0:00:01 --:--:--  0:00:01  280k

# This is the error message I got:

Error: Document has not the mandatory ending %EOF
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

narmi2Author Commented:
@ fmarzocca:  I had a feeling someone was going to say that.
Fabio MarzoccaFreelancerCommented:
"Error: Document has not the mandatory ending %EOF", because pdftotext starts before curl ends...
narmi2Author Commented:
Is it possible to write a script which returns a value to the program calling the script?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.