#!/bin/bash # Created by Rachel Schreiber # Date: 07/14/2016 # Used for uploading data from a file to a device stream in the M2X cloud while IFS= read -r line; do # get date in ISO 8601 format DATE=`date +%Y-%m-%d`T`date +%H:%M:%S`.000Z # send data to m2x stream send=`curl -i "http://api-m2x.att.com/v2/devices//streams//values" -d "{ \"values\": [{ \"value\":$line, \"timestamp\": \"$DATE\" }] }" -H "Content-type: application/json" -H "X-M2X-KEY: "` # get status of whether successfully sent or not status=`echo $send | cut -c 14-19` # check if successfully sent, if not, break and exit application if [ $status = "Accept" ]; then echo Sent $line else echo Error sending $line, exiting application break; fi sleep 60 done < "$1"