Linux BASH script for sending to radmon.org
3 years 4 months ago #5843
by Radslug
Replied by Radslug on topic Linux BASH script for sending to radmon.org
exec=`wget -O /dev/null "http://radmon.org/radmon.php?function=submit&user=$use$
Does this work from the CLI with values instead of variables?
Looks like it could use a little quotes cleanup, no password is sent, $line is not sent, and the r is missing from the user variable?
You might also try it without the exec=
Does this work from the CLI with values instead of variables?
Looks like it could use a little quotes cleanup, no password is sent, $line is not sent, and the r is missing from the user variable?
You might also try it without the exec=
Please Log in or Create an account to join the conversation.
1 year 3 months ago - 1 year 3 months ago #6554
by Mercator
Replied by Mercator on topic Linux BASH script for sending to radmon.org
Gents, (and lady's)
My geiger, connected to raspberry pi W so there is no serial out. So a python script generates a file called /home/pi/geiger/cpm.txt
My bash script to send the last CPM to radmon (influenced by OM1AMJ Thanx for that!) below
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
#!/bin/bash
# Trim the file /home/pi/geiger/cpm.txt to 1 line (Note owner of cpm.txt=root because of reason)
echo "$(tail -1 /home/pi/geiger/cpm.txt)" > /home/pi/geiger/cpm.txt
# read /home/pi/geiger/cpm.txt in the variabele : line
read -r line < /home/pi/geiger/cpm.txt
# Send to radmon
user="USERNAME"
password="PASSWORD"
exec=`wget -O /dev/null "http://radmon.org/radmon.php?function=submit&user=$user&password=$password&value=$line&unit=CPM"`
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
This bash script is called by /etc/crontab every minute.
My geiger, connected to raspberry pi W so there is no serial out. So a python script generates a file called /home/pi/geiger/cpm.txt
My bash script to send the last CPM to radmon (influenced by OM1AMJ Thanx for that!) below
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
#!/bin/bash
# Trim the file /home/pi/geiger/cpm.txt to 1 line (Note owner of cpm.txt=root because of reason)
echo "$(tail -1 /home/pi/geiger/cpm.txt)" > /home/pi/geiger/cpm.txt
# read /home/pi/geiger/cpm.txt in the variabele : line
read -r line < /home/pi/geiger/cpm.txt
# Send to radmon
user="USERNAME"
password="PASSWORD"
exec=`wget -O /dev/null "http://radmon.org/radmon.php?function=submit&user=$user&password=$password&value=$line&unit=CPM"`
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
This bash script is called by /etc/crontab every minute.
Last edit: 1 year 3 months ago by Mercator.
Please Log in or Create an account to join the conversation.
1 year 3 months ago #6555
by jardous
Replied by jardous on topic Linux BASH script for sending to radmon.org
Here is my script that reads values from MQTT and sends them to radmon:
#!/bin/sh
# https://gist.github.com/David-Lor/63fb0be80b67359c8de6230c6b1dafa2
export BROKER='MQTT_BROKER_IP'
export TOPIC="SENSOR_TOPIC"
#https://radmon.org/radmon.php?function=submit&user=jardous&password=2JtiaxVA&value={}&unit=CPM
while true # Keep an infinite loop to reconnect when connection lost/broker unavailable
do
mosquitto_sub -h ${BROKER} -t ${TOPIC}/\# -F "%t %p" | while read -r payload
do
# Here is the callback to execute whenever you receive a message:
topic=$(echo "$payload" | cut -d ' ' -f 1)
cpm=$(echo "$payload" | cut -d ' ' -f 2-)
echo $topic $cpm
wget -q "https://radmon.org/radmon.php?function=submit&user=RADMON_USER&password=PASSWORD&value=$cpm&unit=CPM"
done
sleep 10 # Wait 10 seconds until reconnection
done # & # Discomment the & to run in background (but you should rather run THIS script in background)
Previously I had a Python script that was using PAHO library but it turned out to be somehow unreliable...
#!/bin/sh
# https://gist.github.com/David-Lor/63fb0be80b67359c8de6230c6b1dafa2
export BROKER='MQTT_BROKER_IP'
export TOPIC="SENSOR_TOPIC"
#https://radmon.org/radmon.php?function=submit&user=jardous&password=2JtiaxVA&value={}&unit=CPM
while true # Keep an infinite loop to reconnect when connection lost/broker unavailable
do
mosquitto_sub -h ${BROKER} -t ${TOPIC}/\# -F "%t %p" | while read -r payload
do
# Here is the callback to execute whenever you receive a message:
topic=$(echo "$payload" | cut -d ' ' -f 1)
cpm=$(echo "$payload" | cut -d ' ' -f 2-)
echo $topic $cpm
wget -q "https://radmon.org/radmon.php?function=submit&user=RADMON_USER&password=PASSWORD&value=$cpm&unit=CPM"
done
sleep 10 # Wait 10 seconds until reconnection
done # & # Discomment the & to run in background (but you should rather run THIS script in background)
Previously I had a Python script that was using PAHO library but it turned out to be somehow unreliable...
Please Log in or Create an account to join the conversation.
Moderators: Gamma-Man
Time to create page: 0.192 seconds