4 ms·
This is very interesting, but I can't figure out how to use this in Bash, when I try: xargs -I % curl -X POST "http://sa-api.postmarkapp.com/filter \ -H "
by brdrak 15y ago
This is very interesting, but I can't figure out how to use this in Bash, when I try:
xargs -I % curl -X POST "http://sa-api.postmarkapp.com/filter \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-v \
-d '{"email":"%", "options":"long"}' \
<message
It seems contents of my email message file are processed one line at a time, instead of the entire message passed in place of %
I'm using GNU bash, version 4.1.5(1)-release (x86_64-pc-linux-gnu)
EDIT: added indentation to fix display
- jimktrains2 15y agoPlease, man xargs if you aren't joking. EDIT: Sorry if that came off harsh.
- brdrak 15y agoNo, I'm not joking. I guess I'm just really dense. I've also tried passing -L 100 in addition to -I, but the result is the same.
- jimktrains2 15y agoWhy are you using xargs to read to an entire entry? Why not set it as a var and place it in the comment or take it as stdin?
- brdrak 15y agoI've also tried this: msg=$(cat message) curl -X POST "http://sa-api.postmarkapp.com/filter" \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ -v \ -d '{"email":"'"$msg"'", "options":"long"}' But sa-api.postmarkapp.com returns "error"... :-(
- orenmazor 15y agooh no. I'm sorry! that's the previous url which we moved last minute. I'm going to go through the doc again to make sure there's nothing else out of place :/
- brdrak 15y agoI got it from here: http://spamcheck.postmarkapp.com/doc http://spamcheck.postmarkapp.com/doc
- brdrak 15y agoSo I see you've updated the doc with a new hostname, but I still get an error, so there's something obviously wrong with my method: msg=$(cat message) curl -X POST "http://spamcheck.postmarkapp.com/filter" \ -H "Accept: application/json" \ -H "Content-Type: application/json" \ -v \ -d '{"email":"'"$msg"'", "options":"long"}' * About to connect() to spamcheck.postmarkapp.com port 80 (#0) * Trying 184.73.163.218... connected * Connected to spamcheck.postmarkapp.com (184.73.163.218) port 80 (#0) > POST /filter HTTP/1.1 > User-Agent: curl/7.21.7 (x86_64-pc-linux-gnu) libcurl/7.21.7 OpenSSL/1.0.0e zlib/1.2.3.4 libidn/1.22 libssh2/1.2.8 librtmp/2.3 > Host: spamcheck.postmarkapp.com > Accept: application/json > Content-Type: application/json > Content-Length: 5229 > Expect: 100-continue > < HTTP/1.1 100 Continue < HTTP/1.1 500 Internal Server Error < X-Powered-By: Express < Content-Type: application/json < Connection: keep-alive < Transfer-Encoding: chunked < * Connection #0 to host spamcheck.postmarkapp.com left intact * Closing connection #0 {"error":{}} Wonder if you've got any pointers on how to do this at the shell...