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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

It looks like pdftotext doesn't understand "-" as stdin. try this:

curl [url] | pdftotext /dev/stdin output.txt
Fabio MarzoccaFreelancerCommented:
You should write a script, as the pipe doesnt wait for curl downloading completion. Save the file in /tmp, then pdftotext

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
Build an E-Commerce Site with Angular 5

Learn how to build an E-Commerce site with Angular 5, a JavaScript framework used by developers to build web, desktop, and mobile applications.

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?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux Distributions

From novice to tech pro — start learning today.