cURL and XML

cURL POST request header checks and more in Bash:

"This option is handy to use when you want to store the headers that an HTTP site sends to you. Cookies from the headers could then be read in a second curl invocation by using the -b, --cookie option! The -c, --cookie-jar option is a better way to store cookies."

For many requests, use a loop:

for i in "${IDS[@]}"
    if curl -D - -X POST -o /dev/null | grep 'HTTP/1.1 200 OK'

There's probably a more eloquent way to grep...

curl -s -D - -X POST -o /dev/null | head -n 1 | grep 200


-d = data and thus <XML><Stuff><ID>'$1'</ID></Stuff></XML>

-H content-type: text/xml is also needed.

bash functions that return interpolated strings:

xml_return () {
echo '<Foo xmlns="foobar" xmlns:i=""><Attendant><ID xmlns="foobar">'$1'</ID><ServiceStatus>CLEANING_STARTED</ServiceStatus></Foo>'

keep the format by surrounding the parameter in single quotes.

Bash does not have hash maps, but it's doable. You know, this reminds me, I really need to read up on bash scripting...

Valid XHTML 4.0!

Valid CSS!

Learn CSS

page last modified: 2019-10-21