Your IP : 216.73.216.48
| Current Path : /usr/X11/bin/ |
|
|
| Current File : //usr/X11/bin/winpopup-send |
#!/bin/bash
PATH=/bin:/usr/bin/:/usr/local/bin
# Check input
[ -z "$1" -o -z "$2" ] && exit 1
# Check if file is indeed a file and readable
[ ! -f "$1" -o ! -r "$1" ] && exit 1
KOPETE_RUNNING=x`ps -A|grep -e "kopete$"`
if [ "$KOPETE_RUNNING" = "x" ]; then
if [ -z "$3" ]; then
THIS_SERVER=`uname -n`
else
THIS_SERVER="$3"
fi
if [ "$2" != "$THIS_SERVER" ]; then
ARGS=""
IP=`nmblookup $2 | tail -n +2 | head -1 | cut -f1 -d' '`
if [ "$IP" != "name_query" ]; then
ARGS="-I $IP"
fi
echo -e "Kopete is currently not running.\nYour message was not delivered!" \
| smbclient -N -M $2 $ARGS
fi
else
# Create a unique filename
filename="/var/lib/winpopup/`date +%s_%N`"
# the time...
TIME=`date --iso-8601=seconds`
# the message
MESSAGE=`cat "$1"`
# Put it into the file
echo -e "$2\n$TIME\n$MESSAGE" > $filename
fi
# Remove the message from samba
rm -f "$1"