Linux BASH script for sending to radmon.org

More
2 years 7 months ago #5843 by Radslug
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=

Please Log in or Create an account to join the conversation.

More
7 months 2 days ago - 7 months 2 days ago #6554 by Mercator
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.

 
Last edit: 7 months 2 days ago by Mercator.

Please Log in or Create an account to join the conversation.

More
7 months 1 day ago #6555 by jardous
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...

Please Log in or Create an account to join the conversation.

Moderators: Gamma-Man
Time to create page: 0.136 seconds
Powered by Kunena Forum
Everything's free. Please support us by considering a donation. Log in first!
Solar powered Raspberry Pi 4 server stats: CPU 32% Memory 13% Swap 0% CPU temp=55.0'C Uptime 12:36, Days