summaryrefslogtreecommitdiff
path: root/localshowkannelsms
blob: 46c04bd408a5b32f1cffbc8348782a6b08ca0993 (plain)
  1. #!/bin/sh
  2. #
  3. # /usr/local/sbin/localshowkannelsms
  4. # Copyright 2010 Jonas Smedegaard <dr@jones.dk>
  5. #
  6. # List recently handles sms'es
  7. #
  8. logfilecount="${logfilecount:-2}"
  9. lslogfiles() {
  10. if [ -n "$logfilecount" ]; then
  11. find /var/log/kannel -name 'smsbox.log*' | sort -n -t. -k3 -r | tail -n "$logfilecount"
  12. else
  13. find /var/log/kannel -name 'smsbox.log*' | sort -n -t. -k3 -r
  14. fi
  15. }
  16. #lslogfiles | xargs zcat -f | perl -ne '/^(\S+ +\S+) .*Starting to service <(.*)> from <.*> to <\+4530959593>$/ and print "$1 $2\n"; /^\S+ (\S+) .*sendsms sender:<\S+:\+4530959593> .*msg:<(.*?)>?$/ and print " $1 $2\n"; /^(...................)(?<!\d\d\d\d\-\d\d\-\d\d \d\d:\d\d:\d\d)(.*?)>?$/ and print " $1$2\n"'
  17. lslogfiles | xargs zcat -f | perl -ne '/^(\S+ +\S+) .*Starting to service <(.*)> from <.*> to / and print "$1 $2\n"; /^\S+ (\S+) .*sendsms sender:<\S+:.*msg:<(.*?)>?$/ and print " $1 $2\n"; /^(...................)(?<!\d\d\d\d\-\d\d\-\d\d \d\d:\d\d:\d\d)(.*?)>?$/ and print " $1$2\n"'
  18. exit 0