I'm working on a bash script that will run arbitrary API queries and then write the output to a file. At present, I'm using cURL to send commands to the JSS. This works. The only issue i'm having is that the returned data has no newline characters in it, and is one long line containing the XML data. I've read through the man page for cURL and the only place it mentions preserving newlines is for PUT commands. This is all well and good except for the fact that I'm only interested in GET for this project.
Does anyone know how I can either get cURL to preserve newlines in data received from a GET command, or know of a better tool to use in a bash script? Is something like python, or another language a better way to go? My current script is below for reference.
Thanks in advance!
#!/bin/bash
set -o nounset # Treat unset variables as an error
server="devjss.mycompany.com"
apiBaseURL="https://$server:8443/JSSResource"
apiURLSuffix=$1
apiUser="username"
apiPass="password"
curlCMD="-X GET --noproxy $server -s -u $apiUser:$apiPass $apiBaseURL/$apiURLSuffix"
outfile=~/Desktop/jssReport.xml
echo `curl $curlCMD` > $outfile