Created
January 11, 2017 22:01
-
-
Save goran-mahovlic/278e5b478b2706a2849bd3f4ae121221 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
#removing empty lines if any and save to data2.log | |
awk 'NF > 0' /tmp/data.log > /tmp/data2.log | |
#open data2.log | |
file="/tmp/data2.log" | |
#go thru file line by line | |
while IFS= read -r line | |
do | |
#if $line starts with 5 and it is noot the same as previews one (need a bit tweek here) | |
if [[ ${line:0:1} == "5" ]] && [ "$line" != "$STROLD" ] && [ ! -z "${line}" | |
#upload it to ukhasnet | |
curl --data "origin=LoGoGa&data=$line" http://ukhas.net/api/upload | |
#save it as old line | |
STROLD=$line | |
#backup it to data.backup.log | |
echo $line >> /tmp/data.backup.log | |
#sleep 10s and upload next line if exist | |
sleep 10 | |
fi | |
#close file | |
done <"$file" | |
#remove data.log | |
rm /tmp/data.log /tmp/data2.log | |
#check if cut exists | |
if pidof cat >/dev/null; then | |
echo "Process already running" | |
if not run it | |
else | |
cat /dev/ttyUSB0 > /tmp/data.log& | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment