How do I POST LF with curl command line tool?

Welcome to Programming Tutorial official website. Today - we are going to cover how to solve / find the solution of this error How do I POST LF with curl command line tool? on this date .

I’m trying to POST to the HTTP gateway of an SMS provider (Sybase 365) using CURL from a Linux shell script.

I need to pass the following data (note the [ ] and LF characters)


If I submit a file using the -F parameter, CURL removes the LF e.g.

curl -F @myfile ""

results in this at the server (which is rejected)


Is there anything I can do to avoid this or do I need an alternative tool?

I’m using a file containing my data for testing but I’d like to avoid that in practice and POST directly from the script.


I’ve got this working using -d

request=`printf "[MSISDN]nList=$numbern[MESSAGE]nText=$messagen[END]n"`
response=`curl -s -u $username:$password -d "$request"`

Curiously, if I use -d @myfile (where myfile contains LF separated text), it doesn’t work.

I also tried –data-binary without success.