Hi folks, I am working on a shell script that I can use with the externnotify command in voicemail.conf. All is well and seems ready to rock, except I can't figure out how to tell the script what e-mail address to send the mail messages to. I warn you ahead of time that I am no scripting guru. Basically, I have 14 after-hours mailboxes that all have different e- mail addresses. I want this script to parse the mailbox number from the original command ($2), and then somehow look that up mailbox's address and send an e-mail. It then checks every five minutes to see if the message has been retrieved, and escalates things as necessary. I don't mind the messy solution of defining all 14 addresses in the script itself, though it would be nice to look it up from voicemail.conf or something eventually. I started out using /bin/sh for the scripting, but I assume that this is limiting me with what I can do with variables, etc. The only way I can think of off the top of my head is to use some sort of nested variable, like this subset of my script: Tmpmail=/tmp/dispatch$$.mail ext108=user@domain.dom # Send an e-mail to the appropriate address for this mailbox: echo "724-6066 $2" > $Tmpmail echo "New Voicemail Message #$3 in mailbox $2" >>$Tmpmail cat $Tmpmail | mail -s "$mailsubject" $ext$2 now, the "$ext$2" is what I mean by nested variable. Basically, if I can find a way to make this evaluate as $ext108, and then as user@domain.dom, I would be a happy camper. Is there any way to do this? I know that this is technically not an Asterisk question, but then again, it is. If anyone has wrestled with this in their own externnotify scripts, please let me know Tom PS: I know that perl and other scripting languages would be better for this, but this seemed simpler to me at the time I started. If it can't be done using sh, then I'll start over in perl, but if there's a way to make this work, it's the only thing standing between me and a script that works exactly as I want. -------------------- Tom Rymes Cascade Link Systems www.cascadelinksystems.com (603) 375-1414 "Intelligent technology solutions for small businesses."
Hadley Rich
2005-Nov-17 21:45 UTC
[Asterisk-Users] Help with shell script for externnotify
On Friday 18 November 2005 15:32, Tom Rymes wrote:> Basically, I have 14 after-hours mailboxes that all have different e- > mail addresses. I want this script to parse the mailbox number from ? > the original command ($2), and then somehow look that up mailbox's ? > address and send an e-mail. It then checks every five minutes to see ? > if the message has been retrieved, and escalates things as necessary. ? > I don't mind the messy solution of defining all 14 addresses in the ? > script itself, though it would be nice to look it up from ? > voicemail.conf or something eventually.I'm not sure I understand what you are trying to do, but this may (or may not) help. You mentioned looking up the email field from voicemail.conf, this should do that: EXTEN=`echo $2 | cut -f 1 -d @` EMAIL=`cat voicemail.conf | grep '^$EXTEN' | cut -d ',' -f 3` The above ignores contexts so if you have more than one it will not work. HTH hads -- "At a recent meeting in Snowmass, Colorado, a participant from Los Angeles fainted from hyperoxygenation, and we had to hold his head under the exhaust of a bus until he revived."
Tzafrir Cohen
2005-Nov-18 07:15 UTC
[Asterisk-Users] Help with shell script for externnotify
On Thu, Nov 17, 2005 at 09:32:37PM -0500, Tom Rymes wrote:> Hi folks, > > I am working on a shell script that I can use with the externnotify > command in voicemail.conf. All is well and seems ready to rock, > except I can't figure out how to tell the script what e-mail address > to send the mail messages to. I warn you ahead of time that I am no > scripting guru. > > Basically, I have 14 after-hours mailboxes that all have different e- > mail addresses. I want this script to parse the mailbox number from > the original command ($2), and then somehow look that up mailbox's > address and send an e-mail.This is a mail routing issue. Why not configure the mail server properly? in voicemail.conf configure each extension's email to be '<NUM>@localhost . Handle the forwarding using the mail server's aliases file. This is typically /etc/aliases , but there are variations depending on the specific MTA (postfix? sendmail? exim? qmail?) and on the installation. Run two daily cron jobs that change the contents of the aliases file. Spefically with postfix you can give it a number of aliases files, and thus the cron job can edit one file, run 'newaliases' and be done with it. -- Tzafrir Cohen | tzafrir@jbr.cohens.org.il | VIM is http://tzafrir.org.il | | a Mutt's tzafrir@cohens.org.il | | best ICQ# 16849755 | | friend