0

I'm trying to pipe python stdout output with xargs to curl and fail in this task.

curl is fine to accept input from echo

λ echo https://google.com | xargs curl
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="https://www.google.com/">here</A>.
</BODY></HTML>

but when printing the same from python, the xargs curl input becomes invalid on Windows (with cmder).

This works fine in WSL:

python3 -c"print('https://google.com')" | xargs curl
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="https://www.google.com/">here</A>.
</BODY></HTML>

But on Windows probably some newline/endlines interfere:

λ python -c"print('https://google.com')" | xargs curl
curl: (3) URL using bad/illegal format or missing URL

How do I clean python print output on Windows to make the above command work?

Evgeny
  • 4,173
  • 2
  • 19
  • 39

1 Answers1

0

Should have guessed!

python -c"print('https://google.com', end='')" | xargs curl

as in How to print without newline or space?

I was too much attracted to fidning some argument for xargs that would have done all the job.

Evgeny
  • 4,173
  • 2
  • 19
  • 39