Mailcmd.sh

Aus VDR Wiki
(Unterschied zwischen Versionen)
Wechseln zu: Navigation, Suche
(M)
 
(17 dazwischenliegende Versionen von 10 Benutzern werden nicht angezeigt)
Zeile 1: Zeile 1:
 +
Skript vom [[mailbox-plugin]], wurde ein wenig ''erweitert''.
 +
 +
Für '''"Sie haben Post..."''', geht es in etwa so.
 +
 +
shell> wget -P /mp3 http://www.mailhilfe.de/Download/emailp.wav
 +
shell> lame /mp3/emailp.wav
 +
shell> mv /mp3/emailp.wav.mp3 /mp3/emailp.mp3
 +
 +
Über [[Mp3-plugin#SVDRP Befehle]] '''PLAY''' können nur Sachen abgespielt werden, welche den '''PATH''' in der [[mp3sources.conf]] entsprechen!
 +
 +
{{Box Datei | [[Struktur|$PATH]]/mailcmd.sh |
 
<pre>
 
<pre>
 
#!/bin/sh
 
#!/bin/sh
Zeile 5: Zeile 16:
 
#
 
#
 
# source: vdr-plugin mailbox
 
# source: vdr-plugin mailbox
 +
#
 +
# $1: name of the account
 +
# $2: user name
 +
# $3: is a dummy (will eventually become host-name)
 +
# $4: is a dummy (will eventually become "POP3" | "IMAP")
 +
# $5: number of new mails in the account
 +
# $6: total-number of mails in the account
  
#------------------------------------------------------------------
+
# CONFIG START
#    get params
+
  INTERVAL="1"
#------------------------------------------------------------------
+
  SOUNDFILE="/mp3/emailp.mp3"  # need mp3-plugin >= 0.9.15
CMDNAME=`basename $0`
+
# CONFIG END
ACCOUNTNAME=$1
+
USERNAME=$2
+
# $3 is a dummy (will eventually become host-name)
+
# $4 is a dummy (will eventually become "POP3" | "IMAP")
+
COUNT_NEW=$5
+
COUNT_TOTAL=$6
+
  
#------------------------------------------------------------------
+
if [ "$5" -ne 0 -a "$5" -ne -1 ] ; then
#     set some variables
+
     logger -t ${0##*/} "===================================="
#------------------------------------------------------------------
+
    logger -t ${0##*/} "AccountName : $1"
LOGCMD="logger -t $CMDNAME"
+
     logger -t ${0##*/} "UserName   : $2"
SVDRPSEND="/usr/local/bin/svdrpsend.pl"
+
    logger -t ${0##*/} "New / Total : $5 / $6"
 
+
    logger -t ${0##*/} "===================================="
#------------------------------------------------------------------
+
     screen -dm sh -c " \
#     log the parameters
+
c=0 ; \
#------------------------------------------------------------------
+
until [ \$c -eq \${INTERVAL:-1} ] ; do \
$LOGCMD "========================================================"
+
    svdrpsend.pl -p ${VDR_PORT:-2001} MESG \""$"New m@il in"" $1 ...\" ; \
$LOGCMD "svdrpsend      : '$SVDRPSEND'"
+
    c=\$((c+1)) ; \
$LOGCMD "AccountName     : '$ACCOUNTNAME'"
+
    sleep 1s ; \
$LOGCMD "UserName       : '$USERNAME'"
+
done ; \
$LOGCMD "New / Total     : $COUNT_NEW / $COUNT_TOTAL"
+
if [ -e \"$SOUNDFILE\" ] ; then \
$LOGCMD "========================================================"
+
    svdrpsend.pl -p ${VDR_PORT:-2001} PLUG mp3 PLAY \"$SOUNDFILE\" ; \
 
+
fi
#------------------------------------------------------------------
+
    "
#     send a message to vdr
+
#------------------------------------------------------------------
+
EXTRET=0
+
if test "$COUNT_NEW" -ne "0"; then
+
  $SVDRPSEND "MESG New mail in $ACCOUNTNAME";
+
  EXTRET=$?
+
#else
+
$SVDRPSEND "MESG NO mail in $ACCOUNTNAME";
+
 
fi
 
fi
 
if test "$EXTRET" != "0"; then
 
  $LOGCMD "unable to execute $SVDRPSEND"
 
  $LOGCMD "========================================================"
 
fi
 
 
exit $EXTRET
 
 
</pre>
 
</pre>
 +
}}
  
[[Kategorie:Scripts]]
+
[[Kategorie:Skripte]]

Aktuelle Version vom 12. Juni 2006, 09:04 Uhr

Skript vom mailbox-plugin, wurde ein wenig erweitert.

Für "Sie haben Post...", geht es in etwa so.

shell> wget -P /mp3 http://www.mailhilfe.de/Download/emailp.wav
shell> lame /mp3/emailp.wav
shell> mv /mp3/emailp.wav.mp3 /mp3/emailp.mp3

Über Mp3-plugin#SVDRP Befehle PLAY können nur Sachen abgespielt werden, welche den PATH in der mp3sources.conf entsprechen!

Datei
$PATH/mailcmd.sh
#!/bin/sh
#
# mailcmd.sh
#
# source: vdr-plugin mailbox
#
# $1: name of the account
# $2: user name
# $3: is a dummy (will eventually become host-name)
# $4: is a dummy (will eventually become "POP3" | "IMAP")
# $5: number of new mails in the account
# $6: total-number of mails in the account

# CONFIG START
  INTERVAL="1"
  SOUNDFILE="/mp3/emailp.mp3"  # need mp3-plugin >= 0.9.15
# CONFIG END

if [ "$5" -ne 0 -a "$5" -ne -1 ] ; then
    logger -t ${0##*/} "===================================="
    logger -t ${0##*/} "AccountName : $1"
    logger -t ${0##*/} "UserName    : $2"
    logger -t ${0##*/} "New / Total : $5 / $6"
    logger -t ${0##*/} "===================================="
    screen -dm sh -c " \
	c=0 ; \
	until [ \$c -eq \${INTERVAL:-1} ] ; do \
	    svdrpsend.pl -p ${VDR_PORT:-2001} MESG \""$"New m@il in"" $1 ...\" ; \
	    c=\$((c+1)) ; \
	    sleep 1s ; \
	done ; \
	if [ -e \"$SOUNDFILE\" ] ; then \
	    svdrpsend.pl -p ${VDR_PORT:-2001} PLUG mp3 PLAY \"$SOUNDFILE\" ; \
	fi
    "
fi