Answering Machine/callerID & perl email script

M

Mr Bill

Hello,
I'm running Linux MDK 10.1 and using the system as an answering machine
amongst other things. I don't even begin to understand perl scripting so I
could use some assistance please. The machine is set up to answer incoming
voice calls using vgetty. The voice message is then emailed to me in .wav
format using the voice module on webmin. I'd like to be able to pass the
caller ID and caller name information as text to the email. The logfile
contains this information (at least I figured out how to capture that
info). Revelent perl script (/usr/libexec/webmin/vgetty/email.pl) and a
snip of the vgetty.ttySx logfile are below. I think this might also be
useful of others. Thanks.
Bill


#!/usr/bin/perl
# email.pl
# Email a received message in WAV format to some address

$no_acl_check++;
require './vgetty-lib.pl';
&foreign_check("mailboxes") || die "Read User Mail module not installed";
&foreign_require("mailboxes", "mailboxes-lib.pl");

# Get the WAV format message and construct the email
open(OUT, "rmdtopvf $ARGV[0] 2>/dev/null | pvftowav 2>/dev/null |");
while(read(OUT, $buf, 1024)) {
$wav .= $buf;
}
close(OUT);
$now = localtime(time());
$host = &get_system_hostname();
$body = "Voicemail message received at $now by $host";
$mail = { 'headers' => [ [ 'From', &mailboxes::get_from_address() ],
[ 'To', $config{'email_to'} ],
[ 'Subject', 'Voicemail message' ] ],
'attach' => [ { 'headers' => [ [ 'Content-Type', 'text/plain' ] ],
'data' => $body },
{ 'headers' => [ [ 'Content-Transfer-Encoding',
'base64' ],
[ 'Content-Type',
'audio/wav;
name="voicemail.wav"' ]],
'data' => $wav } ]
};

# Send the email
&mailboxes::send_mail($mail);

############
Logfile info
############



06/09 10:48:14 yS0 vgetty: experimental test release 0.9.33 / 26Dec02
06/09 10:48:14 yS0 mgetty: experimental test release 1.1.30-Dec16
06/09 10:48:14 yS0 reading generic configuration from config
file /etc/mgetty+sendfax/voice.conf
06/09 10:48:14 yS0 reading program vgetty configuration from config
file /etc/mgetty+sendfax/voice.conf
06/09 10:48:14 yS0 reading port ttyS0 configuration from config
file /etc/mgetty+sendfax/voice.conf
06/09 10:48:14 yS0 check for lockfiles
06/09 10:48:14 yS0 locking the line
06/09 10:48:14 yS0 lowering DTR to reset Modem
06/09 10:48:15 yS0 send: \d\d\d+++\d\d\dAT&FE1V1&D2&C1S0=0S41=1#CID=1[0d]
06/09 10:48:18 yS0 waiting for ``OK'' ** found **
06/09 10:48:18 yS0 mdm_send: 'ATI'
06/09 10:48:18 yS0 Generic Rockwell modem (56000)
06/09 10:48:18 yS0 mdm_send: 'ATI3'
06/09 10:48:18 yS0 mdm_send: 'ATI4'
06/09 10:48:18 yS0 additional info: 'a007840284C6002F'
06/09 10:29:02 yS0 modem quirks: 0004
06/09 10:29:02 yS0 mdm_send: 'AT+FCLASS=2' -> OK
06/09 10:29:02 yS0 mdm_send: 'AT+FCLASS=0' -> OK
06/09 10:29:02 yS0 mdm_send: 'AT+FAA=1;+FCR=1' -> OK
06/09 10:29:02 yS0 mdm_send: 'AT+FBOR=0' -> OK
06/09 10:29:02 yS0 mdm_send: 'AT+FLID="49 115 xxxxxxxx"' -> OK
06/09 10:29:03 yS0 mdm_send: 'AT+FDCC=1,5,0,2,0,0,0,0' -> OK
06/09 10:29:03 yS0 detecting voice modem type
06/09 10:29:03 yS0 Rockwell detected
06/09 10:29:04 yS0 initializing ROCKWELL voice modem
06/09 10:29:05 yS0 waiting...
06/09 10:47:22 yS0 wfr: waiting for ``RING''
06/09 10:47:22 yS0 wfr: waiting for ``RING''
06/09 10:47:22 yS0 wfr: waiting for ``RING''
06/09 10:47:28 yS0 wfr: waiting for ``RING''
06/09 10:47:34 yS0 reading ring_type ring configuration from config
file /etc/mgetty+sendfax/voice.conf
06/09 10:47:36 yS0 playing voice
file /var/spool/voice/messages/v-25820-1108931595.rmd
06/09 10:47:57 yS0 recording voice
file /var/spool/voice/incoming/v-3240-1118332056-6306689453.rmd
06/09 10:48:09 yS0 vgetty: <DLE> <ETX> received
06/09 10:48:13 yS0 closing voice modem device
06/09 10:48:13 ##### message keep, length=00:00:13, name='LastName,
FirstName', caller=1234567890, dev=ttyS0, pid=3240

06/09 10:48:13 yS0 vgetty: Executing shell
script /etc/webmin/vgetty/email.pl with shell /bin/sh
--
 
B

Brian Wakem

Mr said:
Hello,
I'm running Linux MDK 10.1 and using the system as an answering machine
amongst other things. I don't even begin to understand perl scripting so I
could use some assistance please. The machine is set up to answer
incoming
voice calls using vgetty. The voice message is then emailed to me in .wav
format using the voice module on webmin. I'd like to be able to pass the
caller ID and caller name information as text to the email. The logfile
contains this information (at least I figured out how to capture that
info). Revelent perl script (/usr/libexec/webmin/vgetty/email.pl) and a
snip of the vgetty.ttySx logfile are below. I think this might also be
useful of others. Thanks.
Bill
<snip>


I would rewrite email.pl to scan the log file and extract the data you need.

Sending a wav by email is a bit cumbersome. I'd convert it to mp3 first.
 
M

Mr Bill

Brian said:
<snip>


I would rewrite email.pl to scan the log file and extract the data you
need.

Sending a wav by email is a bit cumbersome. I'd convert it to mp3 first.
That would be very helpful...mp3 works too if that's more convenient.
Logfile location is /var/log/vgetty.ttyS0. I assume the extract of the
logfile would look for the last appropriate entry for name= and caller= ?
I greatly appreciate your willingness to assist. Thanks.

Bill
 
B

Brian Wakem

Mr said:
That would be very helpful...mp3 works too if that's more convenient.
Logfile location is /var/log/vgetty.ttyS0. I assume the extract of the
logfile would look for the last appropriate entry for name= and caller= ?
I greatly appreciate your willingness to assist. Thanks.

Bill


I'm not going to write it for you. If you need help with anything specific
I may be able to oblige.
 
M

Mr Bill

Brian said:
I'm not going to write it for you. If you need help with anything
specific I may be able to oblige.

Teach a man to fish? LOL I'll give it a shot and let you know if I need
help sorting it out. I haven't touched any programming since PL/1,
Fortran, Cobol since college days. Don't imagine it'd be more than a half
dozen lines of code even for me. Google> perl script> tutorital here I
come. Thanks.
Bill
 
A

A. Sinan Unur

Brian Wakem wrote:

Teach a man to fish? LOL I'll give it a shot and let you know if I
need help sorting it out. I haven't touched any programming since
PL/1, Fortran, Cobol since college days. Don't imagine it'd be more
than a half dozen lines of code even for me. Google> perl script>
tutorital here I come. Thanks.


You might benefit from reading the posting guidelines for this group.
They contain valuable information on how to help yourself and help
others help you.

See also:

<URL: http://learn.perl.org/>

<URL: http://theoryx5.uwinnipeg.ca/CPAN/perl/pod/perlfaq.html>

Sinan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top