1

I am using curl to post some urlencoded content to a URL, and I want the content of the curl command to come from a pipe. Basically...

... | curl -s --data-urlencode '{\"text\":\"$PIPE_RESULT\"}' http://...

I thought $0 might work, but I get a invalid_payload error with the simple text of:

echo "http://www.example.com" | curl -s --data-urlencode '{"text\":\"$0\"}' https:/...

1 Answer 1

5

xargs to the rescue!

echo "http://www.example.com" | \
xargs -I moo curl -s --data-urlencode '{"text\":\"moo\"}' https://example.com

The 'moo' string given to xargs means that it will replace 'moo' in the following string with the contents it read from stdin.

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.