Discussion:
using CURL.EXE
(too old to reply)
Martin Gerber
2018-09-06 13:39:55 UTC
Permalink
Hi,

I recently started digging into curl.exe and I'm very impressed by it!

But here is a thing I do not understand.

A lot of websites show command-lines that are very long.For that purpose
they append a backslash '\' char.

e.g.
curl --request GET \
--url https://jsonplaceholder.typicode.com/todos/1


When I enter that command exactly as it is (or paste it) into a
windows-cmd-box it doesn't work - obviously curl.exe does not use the
'\' as a line continuation.

How can that be acomplished??
R.Wieser
2018-09-06 14:03:02 UTC
Permalink
Martin,
obviously curl.exe does not use the '\' as a line continuation.
Correct (it would not be able to either - it doesn't control the
commandline).

So ? Just move the URL to directly after the command. Problem solved (you
can enter upto 260 chars on the commandline, which "should be enough for
everyone" (c) ).

Explanation: *if* a line-continuation character would be accepted, its would
be done the shell (OS), not the command.

Regards,
Rudy Wieser
Martin Gerber
2018-09-07 07:55:27 UTC
Permalink
Post by R.Wieser
So ? Just move the URL to directly after the command. Problem solved (you
can enter upto 260 chars on the commandline, which "should be enough for
everyone" (c) ).
Hi Rudy,

thanks for your explanation!

I just thought it would be somehow possible to just feed the the posted
code into curl...

Regards!
R.Wieser
2018-09-07 08:31:38 UTC
Permalink
Martin,
Post by Martin Gerber
thanks for your explanation!
You're welcome. :-)
Post by Martin Gerber
I just thought it would be somehow possible to just feed
the posted code into curl...
You're not doing that.

You're feeding that "code" (command actually) to the command-shell. It
will than parse that line, start the "curl.exe" program and supply it with
whatever it was followed with.

In your case the curl.exe program will only see " --request GET \" as its
arguments*, and will (probably)complain about the missing URL (as well as an
unrecognised "\" argument).

*if you're lucky the command-shell will 'remember' the second line of your
paste ("--url https://jsonplaceholder.typicode.com/todos/1") and execute it
next - which should cause another error (no command found).


You still can execute that command though, but it needs a bit of work first:
paste the two lines into a text-editor, and than remove the "\" and move the
"--url ..." part to behind the get:

[on a single line]
curl --request GET --url https://jsonplaceholder.typicode.com/todos/1
[/on a single line]

After that just copy-and-paste the result to the commandline.

Hope that helps.

Regards,
Rudy Wieser
Post by Martin Gerber
Post by R.Wieser
So ? Just move the URL to directly after the command. Problem solved (you
can enter upto 260 chars on the commandline, which "should be enough for
everyone" (c) ).
Hi Rudy,
thanks for your explanation!
I just thought it would be somehow possible to just feed the the posted
code into curl...
Regards!
Martin Gerber
2018-09-11 10:04:05 UTC
Permalink
Hello Rudi,

you're absolutely right!
Post by R.Wieser
paste the two lines into a text-editor, and than remove the "\" and move the
[on a single line]
curl --request GET --url https://jsonplaceholder.typicode.com/todos/1
[/on a single line]
After that just copy-and-paste the result to the commandline.
Thank you very much!

:-)
R.Wieser
2018-09-11 10:35:46 UTC
Permalink
Martin,
Post by Martin Gerber
Post by R.Wieser
After that just copy-and-paste the result to the commandline.
Thank you very much!
You're welcome. :-)

Regards,
Rudy Wieser

Loading...