PDA

View Full Version : [Perl? commandline?] sending WAV to default audio output


adam
13th December 2004, 12:57 PM
Hey
I have a perl script working with my superkaramba to check my mail frequently. I was wondering how can I plug in a command to play a WAV file whenever a mail comes.

#!/usr/bin/perl
use Net::POP3;

my $ServerName = $ARGV[0];

# If your username contains a @ character you
# must replace it with \@
my $UserName = $ARGV[1];
my $Password = $ARGV[2];
my $pop3 = Net::POP3->new($ServerName);

if (!$pop3) {
print "Błąd";
}

my $Num_Messages = $pop3->login($UserName, $Password) + 0;

if ( $Num_Messages == 1 ){
print $Num_Messages ." wiadomości\n";
}
elsif ( $Num_Messages > 1 ){
print $Num_Messages ." wiadomości\n";
}
else{
print "0 wiadomości\n";
}

$pop3->quit();

bryancole
13th December 2004, 01:53 PM
I did something similar with python by piping a sound stream directly to the "play" command (or 'aplay', if you're using ALSA) (this was before I discovered python has a sound-module included, as I sure perl has too ...). Since you've already got you sound file, just execute "play mysound.wav" as a shell command from perl.

adam
13th December 2004, 02:27 PM
I have never programmed Perl :(
tried exec("play mail.wav"); and system ("play mail.wav"); and `play mail.wav`; - didn't make it.

Drine
13th December 2004, 03:08 PM
Can't really hepl u with perl. ur one of the only people online just wonderin if u can help me with some topics?

adam
13th December 2004, 03:43 PM
@Drine: I'm afraid I don't get you, forget it

Gajuwaka Travel Photos - Maksi Photos on Instagram - Faroe Islands Photos on Instagram