Reputation: 607
I'm trying to run a curl command such as:
curl -Sks -XPOST https://localhost:9999/some/local/service -d 'some text arguments'
The above works fine. However, when I place
'some text arguments'
in a file and call the command as:
curl -Sks -XPOST https://localhost:9999/some/local/service -d `cat file_with_args`
I get many exceptions from the service. Does anyone know why this is?
Thanks!
Upvotes: 0
Views: 602
Reputation: 183201
If the file contains 'some text arguments'
, then your command is equivalent to this:
curl -Sks -XPOST https://localhost:9999/some/local/service -d \'some text arguments\'
— that is, it's passing 'some
, text
, and arguments'
as three separate arguments to curl
.
Instead, you should put just some text arguments
in the file (no single-quotes), and run this command:
curl -Sks -XPOST https://localhost:9999/some/local/service -d "`cat file_with_args`"
(wrapping the `cat file_with_args`
part in double-quotes so that the resulting some text arguments
doesn't get split into separate arguments).
Incidentally, I recommend writing $(...)
rather than `...`
, because it's more robust in general (though in your specific command it doesn't make a difference).
Upvotes: 3