Re: Abspielen von aufgenommenen i4btel-Dateien will nicht

From: Dominik Brettnacher <domi(at)saargate.de>
Date: Sun, 3 Nov 2002 01:25:12 +0100 (CET)

On Sun, 3 Nov 2002, Bjoern Engels wrote:

> Gut, dann mache ich mich mal dran, die Dateien per Mail an die
> Workstations zu verschicken.

Da Du schon der zweite bist, der das erwähnt, schicke ich das Script
einfach mal über die Liste, mit dem ich diese Mails versende. Es ist etwas
rudimentär und unsauber, aber immerhin auch schon seit fast drei Jahren im
Einsatz:

#!/usr/bin/perl
# answers a call and mails the spoken message
# -D device -d destination -s source

use Getopt::Std;
use MIME::Lite;

$SIG{'HUP'} = 'IGNORE';

$address = "domi";
$dir = "/usr/share/isdn/sprueche";

MIME::Lite->send('sendmail', "/usr/sbin/sendmail");

# options in $opt_D, $opt_d, $opt_s
getopt('Dds');

($sec,$min,$hour,$mday,$mon,$year) = localtime(time); $mon += 1; $year += 1900;

$ansage = get_random_file($dir);
system("dd bs=2k if=$ansage of=$opt_D");
system("/usr/sbin/isdntelctl -c -u $opt_D");
system("dd bs=2k if=/usr/share/isdn/beep.al of=$opt_D");
chomp($tmpfile = `mktemp /tmp/answeringmachine-XXXXX`);
system("dd bs=2k if=$opt_D of=$tmpfile");

$msg = new MIME::Lite
        From => $sender,
        To => $address,
        Subject => "Anruf von $opt_s.",
        Type => "multipart/mixed"
        ;
attach $msg
        Type => "text/plain",
        Encoding => "quoted-printable",
        Data => sprintf("Am %02i.%02i.%i um %02i:%02i Uhr rief $opt_s auf $opt_d an.\n",$mday,$mon,$year,$hour,$min)
        ;
attach $msg
        Type => "audio/x-wav",
        Encoding => "base64",
        Path => "/usr/local/bin/sox -t al $tmpfile -t wav - |",
        Filename => sprintf("%04i.%02i.%02i-%02i.%02i.wav",$year,$mon,$mday,$hour,$min)
        ;

open(SENDMAIL,"|sendmail -t");
$msg->print(\*SENDMAIL);
close(SENDMAIL);

unlink($tmpfile);

sub get_random_file {
        my $dir = shift @_;
        my $file,@files;

        opendir(DIR,$dir);
        while($file = readdir(DIR))
        {
                unless($file eq "." || $file eq "..")
                {
                        push(@files,$dir . "/" . $file);
                }
        }
        closedir(DIR);

        $files[int(rand($#files+1))];
}

-- 
Dominik
To Unsubscribe: send mail to majordomo(at)de.FreeBSD.org
with "unsubscribe de-bsd-questions" in the body of the message
Received on Sun 03 Nov 2002 - 01:25:46 CET

search this site