1
我嘗試使用Skype4Py爲Nagios通知。我已經可以從命令行發送消息。現在我嘗試將換行符(回車符)插入消息正文中。我使用以下腳本發送通知: /usr/local/nagios/sbin/skype_alert.sh my_skype_login「RECOVERY \ n」「Host:nagios-test \ r」「Service:PING」「Info:PING OK 1.22 MS「:Skype4Py - 插入行分隔
#!/bin/bash
export DISPLAY=:0
PT=`which python`
SKYPE_LOGIN=$1
SKYPE_MESSAGE="${@:2}"
$PT /usr/local/nagios/sbin/skype_alert.py $SKYPE_LOGIN "$SKYPE_MESSAGE"
/usr/local/nagios/sbin/skype_alert.py:
#!/usr/bin/python
import Skype4Py
import sys
skype = Skype4Py.Skype()
skype.Attach()
user = sys.argv[1]
msg=' '.join(sys.argv[2:])
skype.SendMessage(user, msg)
有人可以告訴我如何在郵件中插入換行符(回車)?我試圖\n
\r
等..
你嘗試逃避反斜槓? –
我試過了:/usr/local/nagios/sbin/skype_alert.sh「my_skype_login」「RECOVERY Host:nagios-test \\ n Service:PING Info:PING OK 1.221342ms」 – whi1test
UPDATE:Here is solution:http:// python.su/forum/topic/29784/?page=1#post-161885 – whi1test