I've got a text file which looks like this:
b4238ca2-cb8d-11e4-8731-1681e6b88ec1,https,username,password,ipaddress b4238f0e-cb8d-11e4-8731-1681e6b88ec1,https,username,password,ipaddress b4239058-cb8d-11e4-8731-1681e6b88ec1,https,username,password,ipaddress
NOTE: username, password and ip address have all been changed, so as not expose sensitive info, they are real in my text file I'm using.
I've written the following bash scripting to read line by line and put each item into an array. Previously this worked, however now it is within a process substitution, it's not longer working. I'm assuming it's to do with how I am accessing the array elements, but I'm not sure what is wrong. Snippet below:
i=0 declare -a devices while read line do devices[i]=$line ((i++)) done < test_data.txt timestamp=$(date +"%s") echo "${devices[@]}" IFS="," declare -a devarr for device in "${devices[@]}" do devarr=($device) read dateStrNew dateStrOld < <(curl -k -q "${devarr[1]}://${devarr[2]}:${devarr[3]}@${devarr[4]}/camerainfo" | html2text | gawk '/Newest Sequence/ { new=$3" "$4 }/Oldest Sequence/ {old=$3" "$4}END {OFS=","; print new,old }')
Also, I tried the following based on a combo of some alternative code that was suggested to an earlier question, along with some other code I came across while researching, but it also doesn't work. However, it would massively simplify things if it did. Could this work and is a better solution?
while read -u 3 line do read UUID protocol username passwd ip_address curl_call="${protocol}://${ip_address}:${username}@${passwd}/report" echo $curl_call read dateStrNew dateStrOld < <(curl -k -q "$curl_call" | html2text | gawk'/Newest Sequence/ { new=$3" "$4 }/Oldest Sequence/ {old=$3" "$4}END {OFS=",";print new,old }') done 3< test_data.txt
Any help much appreciated, as it's going to be a long night regardless! Thanks!
while IFS=',' read -r UUID protocol username passwd ip_address ; do ... done < test_data.txt