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
--
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
--