Reputation: 15
I have a device on my network that is posting data to an html page. I need to be able to collect the data from the page and insert it into my database so I can have historical reference to the data. I am able to use the following command to retrieve the fields from the site. The result returns three numbers separated by a line break.
I would like to run this as a linux cron job, so I would like to use a linux script to:
My command line to retrieves the information is below. This works great for parsing out the data from the device:
curl -s http://local_device.com/dtm.html?address=C5:0 | grep -Po '[0-9]+(?=[^0-9]+(C5:2<|C5:6<|C5:13))'
Upvotes: 0
Views: 300
Reputation: 781
see below for a reference, since they are numbers, I did not quote them:
set -- $(curl -s http://local_device.com/dtm.html?address=C5:0 | grep -Po '[0-9]+(?=[^0-9]+(C5:2<|C5:6<|C5:13))')
C5_2=$1
C5_6=$2
C5_13=$3
mysql -e "
INSERT INTO db.table VALUES ($C5_2, $C5_6, $C5_13)
"
Upvotes: 1