<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.domoticz.com/index.php?action=history&amp;feed=atom&amp;title=Notifications_to_PC_with_Snarl</id>
	<title>Notifications to PC with Snarl - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.domoticz.com/index.php?action=history&amp;feed=atom&amp;title=Notifications_to_PC_with_Snarl"/>
	<link rel="alternate" type="text/html" href="https://wiki.domoticz.com/index.php?title=Notifications_to_PC_with_Snarl&amp;action=history"/>
	<updated>2026-09-18T23:41:21Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.46.0</generator>
	<entry>
		<id>https://wiki.domoticz.com/index.php?title=Notifications_to_PC_with_Snarl&amp;diff=19010&amp;oldid=prev</id>
		<title>Walter vl at 18:23, 12 December 2025</title>
		<link rel="alternate" type="text/html" href="https://wiki.domoticz.com/index.php?title=Notifications_to_PC_with_Snarl&amp;diff=19010&amp;oldid=prev"/>
		<updated>2025-12-12T18:23:23Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw-interface=&quot;&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 18:23, 12 December 2025&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l289&quot;&gt;Line 289:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 289:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Python]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category:Python]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:Notifications]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key pkjv172828_mw1-mw_:diff:1.41:old-14852:rev-19010:php=table --&gt;
&lt;/table&gt;</summary>
		<author><name>Walter vl</name></author>
	</entry>
	<entry>
		<id>https://wiki.domoticz.com/index.php?title=Notifications_to_PC_with_Snarl&amp;diff=14852&amp;oldid=prev</id>
		<title>Walter vl at 14:56, 30 December 2020</title>
		<link rel="alternate" type="text/html" href="https://wiki.domoticz.com/index.php?title=Notifications_to_PC_with_Snarl&amp;diff=14852&amp;oldid=prev"/>
		<updated>2020-12-30T14:56:27Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
Domoticz supports [[notifications]] to mobile devices with [https://www.domoticz.com/wiki/Telegram_Bot Telegram] (free), Pushover, Pushsafer and Prowl (paid apps). A good notification system to the PC desktop was missing because I do not carry the mobile phone at all times. Pushover can push messages to the desktop but this only works in a browser.&lt;br /&gt;
&lt;br /&gt;
When searching for notification receivers I found [http://snarl.fullphat.net/ Snarl] which is a great notification system for events like low diskspace, IM events, played music, time, anything you can think of!&lt;br /&gt;
Only the link from Domoticz to Snarl was missing but in a few hours the author of Snarl popped out a Python script that connects to Snarl from the Pi.&lt;br /&gt;
&lt;br /&gt;
Notifications to Snarl on your desktop or laptop only work on your local network, that is, the network in where Domoticz runs.&lt;br /&gt;
&lt;br /&gt;
==Installation==&lt;br /&gt;
&lt;br /&gt;
Get the Snarl installer here: [http://sourceforge.net/projects/snarlwin/files/Snarl/Current%20Release/ Download Snarl-3.1-setup.exe (9.9 MB)].&lt;br /&gt;
&lt;br /&gt;
It is also possible to get Snarl notifying on [http://snarl.fullphat.net/using-snpd-with-os-x/ OSX or Linux].&lt;br /&gt;
&lt;br /&gt;
Make sure to allow traffic to Snarl listening on port 9887 in your desktop firewall.&lt;br /&gt;
&lt;br /&gt;
Then get the Python script here: [http://sourceforge.net/projects/snarlwin/files/Extras/snp-send/ Download snp-send-0.5.zip (3.8 KB)] .&lt;br /&gt;
&lt;br /&gt;
Copy snp-send.py to /home/pi/domoticz/scripts, you can use [http://winscp.net/eng/download.php WinSCP] for that.&lt;br /&gt;
&lt;br /&gt;
On the Domoticz Pi, make sure you have Python3 installed.  The command &amp;#039;&amp;#039;&amp;#039;Python3&amp;#039;&amp;#039;&amp;#039; will give an error when it is not present or enter Python3 (ctrl-D to leave). This command will install Python3:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	sudo apt-get install python3&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
About 30MB diskspace is used totally.&lt;br /&gt;
&lt;br /&gt;
Now you can fire your first test command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	python3 snp-send.py -d 192.168.2.4 -b  &amp;#039;Hello, world&amp;#039; -i &amp;#039;!system-info&amp;#039; -n &amp;#039;!windowslogon&amp;#039; -s &lt;br /&gt;
        snp-send: connecting to 192.168.2.4:9887...connected! &lt;br /&gt;
        snp-send: notification sent &lt;br /&gt;
 &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the IP address to your desktop&amp;#039;s IP.  All possible command options are explained in the Readme in the downloaded snp-send-0.5.zip. If all went well, you will see a text message &amp;#039;&amp;#039;Hello, world&amp;#039;&amp;#039; with an icon and a sound and see two messages on the Pi command line.&lt;br /&gt;
&lt;br /&gt;
Now create a new bash script, or add a line to your existing Pushover notification script in /home/pi/domoticz/scripts:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	nano snarltest.sh &lt;br /&gt;
        #!/bin/bash &lt;br /&gt;
         &lt;br /&gt;
        snp-send: notification sent &lt;br /&gt;
        /usr/bin/python3.2mu /home/pi/domoticz/scripts/snp-send.py -d 192.168.2.4 -b &amp;#039;Hello, world!&amp;#039; -i &amp;#039;!system-yes&amp;#039; -n &amp;#039;d:\shared\fluitje.mp3&amp;#039; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the IP address to your desktop&amp;#039;s, and change or remove the sound option (-n). I borrowed the railway station bell sound from the NS app here :-)&lt;br /&gt;
Save the file with ctrl+X. Then make it executable:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	chmod +x snarltest.sh &lt;br /&gt;
 &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In Domoticz - Switches, edit the switch you want to make notifications. Put this in field &amp;#039;&amp;#039;&amp;#039;On Action&amp;#039;&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	script://home/pi/domoticz/scripts/snarltest.sh &lt;br /&gt;
 &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If all went well, when you toggle the switch to on (or an event does this), then you will see a notification from Snarl on your desktop!&lt;br /&gt;
&lt;br /&gt;
When the desktop is down or Snarl is not running, a message in the Domoticz log is written:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	Thu Feb 5 08:12:48 2015 Error: Error executing script command (home/pi/domoticz/scripts/snarltest.sh). returned: 512 &lt;br /&gt;
 &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Other Stuff==&lt;br /&gt;
&lt;br /&gt;
I snatched the Domoticz icon from the [http://sourceforge.net/projects/domoticz/files/ website] and copied it to the Snarl default icon folder: C:\Program Files\Snarl\etc\default_theme\icons (C:\Program Files (x86)\Snarl\etc\default_theme\icons on x64 systems).&lt;br /&gt;
&lt;br /&gt;
Direct link to the [http://a.fsdn.com/allura/p/domoticz/icon icon picture]. Rename it to domoticz-icon.png.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	python3.2 snp-send.py -d 192.168.2.4 -b  &amp;#039;Door 2 open for 5 minutes&amp;#039; -i &amp;#039;!domoticz-icon&amp;#039; -n &amp;#039;d:\shared\fluitje.mp3&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:snarl_notification.png|Snarl notification on desktop]]&lt;br /&gt;
&lt;br /&gt;
Snarl notification on desktop&lt;br /&gt;
&lt;br /&gt;
==Python code==&lt;br /&gt;
&lt;br /&gt;
Here is the Python 3.2 script for the Raspberry Pi. Just copy it here or get the file [http://sourceforge.net/projects/snarlwin/files/Extras/snp-send/ here]. This is snp-send.py version 0.5.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
# snp-send.py -- multi-platform Snarl notification sender&lt;br /&gt;
# Copyright (C) 2015 full phat products&lt;br /&gt;
&lt;br /&gt;
BUILD_VER = &amp;quot;0.5&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Change log:&lt;br /&gt;
#&lt;br /&gt;
# 0.5 - Even more Python 3.2 friendly&lt;br /&gt;
#&lt;br /&gt;
# 0.4 - Modified socket exception handling to work better on Python 3.2&lt;br /&gt;
#&lt;br /&gt;
# 0.3 - No longer dependent on ipaddress module&lt;br /&gt;
#&lt;br /&gt;
# 0.2 - Added sticky, priority and callback options&lt;br /&gt;
#       Better option handling  &lt;br /&gt;
#       More robust packet building&lt;br /&gt;
#       Validates IP address using ipaddress module&lt;br /&gt;
#&lt;br /&gt;
# 0.1 - initial version&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    import ipaddress&lt;br /&gt;
except ImportError:&lt;br /&gt;
    pass&lt;br /&gt;
&lt;br /&gt;
import socket&lt;br /&gt;
import getopt&lt;br /&gt;
import sys&lt;br /&gt;
#import os&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
class term:&lt;br /&gt;
   PURPLE = &amp;#039;\033[95m&amp;#039;&lt;br /&gt;
   CYAN = &amp;#039;\033[96m&amp;#039;&lt;br /&gt;
   DARKCYAN = &amp;#039;\033[36m&amp;#039;&lt;br /&gt;
   BLUE = &amp;#039;\033[94m&amp;#039;&lt;br /&gt;
   GREEN = &amp;#039;\033[92m&amp;#039;&lt;br /&gt;
   YELLOW = &amp;#039;\033[93m&amp;#039;&lt;br /&gt;
   RED = &amp;#039;\033[91m&amp;#039;&lt;br /&gt;
   BOLD = &amp;#039;\033[1m&amp;#039;&lt;br /&gt;
   UNDERLINE = &amp;#039;\033[4m&amp;#039;&lt;br /&gt;
   END = &amp;#039;\033[0m&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
destport = 9887&lt;br /&gt;
destip = &amp;quot;127.0.0.1&amp;quot;&lt;br /&gt;
content = &amp;#039;&amp;#039;&lt;br /&gt;
priority = 0&lt;br /&gt;
debugmode = False&lt;br /&gt;
&lt;br /&gt;
copyright = term.BOLD + &amp;quot;\nsnp-send &amp;quot; + BUILD_VER + &amp;quot;\n&amp;quot;  + term.END + \&lt;br /&gt;
            &amp;quot;Copyright (c) 2015 full phat products&amp;quot;&lt;br /&gt;
&lt;br /&gt;
usage = &amp;quot;usage: snp-send &amp;quot; \&lt;br /&gt;
        &amp;quot;[-b body] [-c callback] [-d ip] [-i icon] [-n sound] &amp;quot; \&lt;br /&gt;
        &amp;quot;[-p port] [-r priority] [-s] [-t title] \n&amp;quot;&lt;br /&gt;
&lt;br /&gt;
hint =  &amp;quot;&amp;quot; \&lt;br /&gt;
        &amp;quot;  -b    Notification body\n&amp;quot; \&lt;br /&gt;
        &amp;quot;  -c    Callback URL, !bang command or @signal\n&amp;quot; \&lt;br /&gt;
        &amp;quot;  -d    Destination IP address (default is 127.0.0.1)\n&amp;quot; \&lt;br /&gt;
        &amp;quot;  -i    Url, !system icon or UNC path to image file\n&amp;quot; \&lt;br /&gt;
        &amp;quot;  -n    Sound to play\n&amp;quot; \&lt;br /&gt;
        &amp;quot;  -p    Destination TCP port (default is 9887)\n&amp;quot; \&lt;br /&gt;
        &amp;quot;  -r    Notification priority.  Must be between -2 and +2.  Default is 0\n&amp;quot; \&lt;br /&gt;
        &amp;quot;  -s    Requests notification to be displayed sticky (infinite duration)\n&amp;quot; \&lt;br /&gt;
        &amp;quot;  -t    Notification title\n&amp;quot; \&lt;br /&gt;
        &amp;quot;\n&amp;quot; \&lt;br /&gt;
        &amp;quot;Notes\n&amp;quot; \&lt;br /&gt;
        &amp;quot;  - At least one of title, body or icon must be supplied.\n&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#        &amp;quot;  - At least one of &amp;quot; + term.BOLD + &amp;quot;title&amp;quot; + term.END +&amp;quot;, &amp;quot; + term.BOLD + &amp;quot;body&amp;quot; + term.END + &amp;quot; or &amp;quot; + term.BOLD + &amp;quot;icon&amp;quot; + term.END + &amp;quot; must be supplied.\n&amp;quot;&lt;br /&gt;
&lt;br /&gt;
if len(sys.argv) &amp;lt; 2:&lt;br /&gt;
    print(&amp;#039;snp-send: arg missing&amp;#039;)&lt;br /&gt;
    print(usage)&lt;br /&gt;
    sys.exit(0)&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    opts, args = getopt.getopt(sys.argv[1:], &amp;quot;b:c:d:i:n:p:r:st:?&amp;quot;, [&amp;quot;body=&amp;quot;, &amp;quot;debug&amp;quot;, &amp;quot;sticky&amp;quot;, &amp;quot;title=&amp;quot;])&lt;br /&gt;
except getopt.GetoptError:&lt;br /&gt;
    print(&amp;#039;snp-send: arg missing&amp;#039;)&lt;br /&gt;
    print(usage)&lt;br /&gt;
    sys.exit(2)&lt;br /&gt;
&lt;br /&gt;
for o, a in opts:&lt;br /&gt;
    if o == &amp;quot;-d&amp;quot;:&lt;br /&gt;
        destip = a&lt;br /&gt;
&lt;br /&gt;
    elif o == &amp;quot;-p&amp;quot;:&lt;br /&gt;
        try:&lt;br /&gt;
            destport = int(a)&lt;br /&gt;
        except ValueError:&lt;br /&gt;
            print(&amp;#039;snp-send: port must be an intger between 0 and 65535&amp;#039;)&lt;br /&gt;
            sys.exit(2)&lt;br /&gt;
&lt;br /&gt;
    elif o in (&amp;quot;-t&amp;quot;, &amp;quot;--title&amp;quot;):&lt;br /&gt;
        content = content + &amp;#039;title=&amp;#039; + a + &amp;#039;&amp;amp;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
    elif o in (&amp;quot;-b&amp;quot;, &amp;quot;--body&amp;quot;):&lt;br /&gt;
        content = content + &amp;#039;text=&amp;#039; + a + &amp;#039;&amp;amp;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
    elif o == &amp;quot;-c&amp;quot;:&lt;br /&gt;
        content = content + &amp;#039;callback=&amp;#039; + a + &amp;#039;&amp;amp;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
    elif o == &amp;quot;-i&amp;quot;:&lt;br /&gt;
        content = content + &amp;#039;icon=&amp;#039; + a + &amp;#039;&amp;amp;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
    elif o == &amp;quot;-n&amp;quot;:&lt;br /&gt;
        content = content + &amp;#039;sound=&amp;#039; + a + &amp;#039;&amp;amp;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
    elif o == &amp;quot;-r&amp;quot;:&lt;br /&gt;
        # priority&lt;br /&gt;
        try:&lt;br /&gt;
            priority = int(a)&lt;br /&gt;
        except ValueError:&lt;br /&gt;
            print(&amp;#039;snp-send: priority must be an intger between -2 and 2&amp;#039;)&lt;br /&gt;
            sys.exit(2)&lt;br /&gt;
&lt;br /&gt;
        if priority != 0:&lt;br /&gt;
            content = content + &amp;#039;priority=&amp;#039; + a + &amp;#039;&amp;amp;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
    elif o in (&amp;quot;-s&amp;quot;, &amp;quot;--sticky&amp;quot;):&lt;br /&gt;
        content = content + &amp;#039;duration=0&amp;amp;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
    elif o == &amp;quot;-?&amp;quot;:&lt;br /&gt;
        print(copyright)&lt;br /&gt;
        print(usage)&lt;br /&gt;
        print(hint)&lt;br /&gt;
        sys.exit(0)&lt;br /&gt;
&lt;br /&gt;
    elif o == &amp;quot;--debug&amp;quot;:&lt;br /&gt;
        debugmode = True&lt;br /&gt;
&lt;br /&gt;
# validate args&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    ipaddress.ip_address(destip)&lt;br /&gt;
except ValueError:&lt;br /&gt;
    print(&amp;#039;snp-send: invalid destination IP address&amp;#039;)&lt;br /&gt;
    sys.exit(2)&lt;br /&gt;
except NameError:&lt;br /&gt;
    pass&lt;br /&gt;
&lt;br /&gt;
# construct the SNP/3.0 packet&lt;br /&gt;
packet = &amp;#039;SNP/3.0\r\nnotify?&amp;#039;&lt;br /&gt;
&lt;br /&gt;
# add rightstr(content, len(content) -1 )&lt;br /&gt;
packet = packet + content[:-1] + &amp;#039;\r\n&amp;#039;&lt;br /&gt;
&lt;br /&gt;
if debugmode:&lt;br /&gt;
    print(&amp;quot;content:\n&amp;quot; + content)&lt;br /&gt;
&lt;br /&gt;
# TO-DO: add headers&lt;br /&gt;
&lt;br /&gt;
# add footer&lt;br /&gt;
packet = packet + &amp;#039;END\r\n&amp;#039;&lt;br /&gt;
&lt;br /&gt;
if debugmode:&lt;br /&gt;
    print(&amp;quot;packet:\n&amp;quot; + packet)&lt;br /&gt;
&lt;br /&gt;
socket.setdefaulttimeout(5)&lt;br /&gt;
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)&lt;br /&gt;
&lt;br /&gt;
print(&amp;#039;snp-send: connecting to &amp;#039; + destip + &amp;#039;:&amp;#039; + str(destport) + &amp;#039;...&amp;#039;, end = &amp;#039;&amp;#039;)&lt;br /&gt;
sys.stdout.flush()&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
    s.connect((destip, destport))&lt;br /&gt;
except socket.error as e:&lt;br /&gt;
    print(&amp;#039;failed (&amp;#039; + str(e) + &amp;#039;)&amp;#039;)&lt;br /&gt;
    sys.exit(2)&lt;br /&gt;
&lt;br /&gt;
else:&lt;br /&gt;
    print(&amp;#039;connected!&amp;#039;)&lt;br /&gt;
    s.send(bytes(packet, &amp;#039;UTF-8&amp;#039;))&lt;br /&gt;
    print(&amp;#039;snp-send: notification sent&amp;#039;)&lt;br /&gt;
    data = s.recv(1024)&lt;br /&gt;
    s.close()&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
[[Category:Python]]&lt;/div&gt;</summary>
		<author><name>Walter vl</name></author>
	</entry>
</feed>