Example Notification from a Command Line Program
Here is a simple example of a command line notifier. This notifier does the following:
- Calls a python script located in the Intermapper Settings\Tools folder.
- Passes the script two parameters:
- The notification message, using the ${MESSAGE} macro.
- A filename for a log file - The script opens the specified file, (also located in the Tools folder) and appends the message text to it.
Log.py Script
Place this script in the Tools folder in a text file named log.py:
import sys
# options are: message logfile
if __name__ == '__main__':
f = open(sys.argv[2], 'a+')
f.write(sys.argv[1]+'\n')
f.close()
# options are: message logfile
if __name__ == '__main__':
f = open(sys.argv[2], 'a+')
f.write(sys.argv[1]+'\n')
f.close()
Configuring the Command-Line Notifier
Configure a new notifier as follows:
- Create a new notifier.
- Set the Type to Command Line.
- Enter this text in the Command box:
${PYTHON} log.py "${MESSAGE}" test.log - Edit the message and schedule as needed.
- Click Test Notifier Configuration.
- Attach the notifier to one or more devices as described in Attaching_A_Notifier.htm.
When the notifier runs, a file named test.log is created in the Tools folder. Message text is appended to to the log file.