-
Notifications
You must be signed in to change notification settings - Fork 11
SW_NotifyMail
Sometimes a new telex may arrive on one of the teleprinters without you noticing it. For example, because the teleprinters are in the basement due to noise or because you are not at home but on the road or in the office. This small script informs you by e-mail about new telexes and optionally also provides the content of the telex.
It works under Debian-based linux distributions.
-
Install some dependencies:
sudo apt install sendemail inotify-tools libio-socket-ssl-perl libnet-ssleay-perl
-
Replace the dummy contents of the e-mail related variables with functional settings.
-
Check that the archive module is enabled in piTelex and working, for the script relies on the archive messages of piTelex.
-
Set
WATCH
to the path of the piTelex archive directory -
If you want to receive the full telex message text via email, set
MSG=yes
, leave it at the default (empty) otherwise.
-
Copy the script to a location of your choice and make it executable:
chmod +x notify-new-telex.sh
The script can be called as ordinary user or as root. If called as ordinary user be sure that this user has read access to the piTelex archive directory and the files therein.
If the script doesn't work as expected, edit the source code and delete the two "-q" Options temporarily. This makes the output more verbose and helps to find the mistake, hopefully.
-
To start the script automatically at system boot, edit
/etc/rc.local
as root user (sudo nano /etc/rc.local
) and before the lineexit 0
add a line like:/path/to/notify-new-telex.sh 2>&1 &
Take care to copy the redirections and ampersands correctly. After rebooting, check if the script is running:
$ ps ax | grep notify 628 ? S 0:00 /bin/bash /home/pi/piTelex-utils/notify-new-telex.sh 630 ? S 0:00 inotifywait -q -m /home/pi/piTelex-archive -e create 631 ? S 0:00 /bin/bash /home/pi/piTelex-utils/notify-new-telex.sh
And finally, here the source code:
#!/bin/bash
#
# For Debian based linux distros
#
# tool to monitor a directory for new files
# and send notification to an email address
# when new files arrive
#
# depends on packages (install with "apt install ..."):
# sendemail
# inotify-tools
# libio-socket-ssl-perl
# libnet-ssleay-perl
#
# =========================================================
# in telex.json, archive module must be enabled and working
# =========================================================
#
#
#
# =========================================================
# for autostart at system boot, edit /etc/rc.local and add
# *before* the "exit" line:
# ---------------------------------------------------------
# # Monitor for new telex and send notification email
# /path/to/notify-new-telex.sh 2>&1 &
# ---------------------------------------------------------
# Be sure to insert the correct path to the script
# and copy the ampersands and redirections correctly!
# =========================================================
#
#
# Now # some variables:
#
WATCH="/home/pi/piTelex-archive" # Directory where piTelex puts messages
# must correspond to the archive path
# in telex.json
#
FM="telex@mailprovider.de" # From Address
TO="toaddress@maildomain.de" # destination mailaddress
U="username@mailprovider.de" # user
P="password for $U" # password
S="smtphost.mailprovider.de:port" # mailhost and port
#
MSG='' # wether or not to attach the
# telex content to the mail
# anything but '' means "yes"
##############################################################################
HOST=`hostname`
inotifywait -q -m $WATCH -e create |
while read dir action file; do
received=`echo "$file" | grep from`
if [ "$received" ] ; then
if [ $MSG ] ; then
TEXT=`cat ${dir}"${file}" | sed -e s/\>//g | sed -e s/\<//g`
else
TEXT="$received"
fi
sendemail -q -f "$FM" -t "$TO" -xu "$U" -xp "$P" -s "$S" -u "New telex message arrived at $HOST" -m "$TEXT"
fi
done
Consider using release packages for software installation: https://github.com/fablab-wue/piTelex/releases
-
Local use
-
i-Telex
-
Advanced Topics
-
Tools & Gadgets
-
TW39 (current loop)
-
ED1000 (FSK modulation)
-
V.10 (TeKaDe FS200, FS220)
-
SEU-M-board based
- with Austrian AGT (Ö-AGT, current loop)
- as replacement for SEU-B card inside LO2000, LO2001, LO3000