I've created a script that accesses a website with the use of a datafile and outputs the sites responses (one line XML) to an output file. I would like the output to start with the query of the datafile and then the response of the website. When I echo the query one one line and write it to an output file and then write the site's response to the same output file it uses two lines but I only want one line because I would like to end up with a comma separated file that I can import in excel.
This works but with having two lines of data:
while read -r line || [[ -n $line ]]
do
datatogather="$line"
echo $datatogather >>outputfile.txt
curl http://login:[email protected]/application.php?$datatogather >>outputfile.txt
echo >>outputfile.txt
done < datafile.txt
This doesn't work (although it shows the comma in the output file, so that line is being processed):
while read -r line || [[ -n $line ]]
do
datatogather="$line"
echo $datatogather,>>outputfile.txt | curl http://login:[email protected]/application.php?$datatogather >>outputfile.txt
echo >>outputfile.txt
done < datafile.txt
Stripping the output file of it's garbage data with sed was a breeze to figure out, even reading the input file into the site was very easy compared to figuring out how to use a variable more than once in a single line. Hope you can help me.