0

This request works fine on my Linux:

curl -F out=json -F "content=<FILE.html" http://validator.w3.org/nu/

Now I want to modify this curl command and use a string instead of a file. The raw html does not work because this sign "<" is interpreted as redirection by curl and also the sign "!" from

<!DOCTYPE html>

is interpreted by the shell.

I tried to use backslashes but it gets sent to the service endpoint too which does not help either.

Here is the content of FILE.html that I want to send as a string:

<!DOCTYPE html><html><head><title></title></head><body></body></html>
1
  • It might become relevant which OS you do this on Commented Jan 9, 2016 at 0:35

1 Answer 1

2

You can use --form-string instead of -F to make the string literal (ie not parse the less than sign) and just quote the string with single quotes to make the bang lose its meaning to the shell;

curl -F out=json \
   --form-string 'content=<!DOCTYPE html><html><head><title></title></head><body></body></html>' \
   http://validator.w3.org/nu/
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.