Author |
Post |
|
#1 Tue Jan 17, 2012 16:20, 156 months ago.
|
Member
Registered: Feb 2011
Location: Switzerland
|
Ubuntu 10.04: 3.14: Smsd installed from: sources Teltonika G10 : Interface: USB
Hi, sorry, I'm not familiar with perl at all, so I don't really understand what the email2sms script is exactly doing. I got it working so far, anyway.
My problem is: I have an application that is sending email alerts, and I want to convert this alerts to sms. Unfortunately this application does not allow to enter email addresses in the format "SMS +1234567" mail@mail.com
So is it somehow possible to extract the mobile number from the email address if it is in the format 1234567@mail.com?
That would be very helpful.
Thanks in advance, best regards, Matthias
|
|
#2 Wed Jan 18, 2012 15:16, 156 months ago.
|
Member
Registered: Feb 2011
Location: Switzerland
Topic owner
|
Hi again,
okay, I found a code snippet that might do what I need:
PHONENUMBER=`formail -z -x"To:" | cut -d'@' -f1 | sed -e 's/[^0-9\+]//g'`
Is there anbody who has an idea where to place it in the email2sms script?
I tried it this way:
tmp=$(mktemp /tmp/smsgw.XXXXXX) cat >$tmp destinations=`formail -z -x"To:" | cut -d'@' -f1 | sed -e 's/[^0-9\+]//g' < $tmp` #=`formail -zx "To:" < $tmp` IFS=, for destination in $destinations; do destination=${destination## } OUTFILE=$(mktemp /var/spool/sms/outgoing/smsgw.out.XXXXXX) formail -f -I "To:" < $tmp > $OUTFILE chmod 666 $OUTFILE echo "SMS queued to $OUTFILE" done rm $tmp
But without success. Is there anybody out there who could help me? It also would be very helpful if someone could comment the original email2sms script: if I could understand what it is doing, I think could manage it by my own... Particularly what is the destination=${destination## } line doing?
Any help is very appreciated.
Thanks, Matthias
|