[ABQ-pm] input/output from filehandle

Jody Harris havoc at harrisdev.com
Tue Apr 8 20:13:15 PDT 2008


I'm trying to get some information from mplayer's -slave mode.

I can start mplayer in slave mode with perl, but how do I send it
commands and get information back?

Sending the info to the filehandle is easy enough, but how do I read
the response?

here's the (broken, mid-hack) scriptlet so far:


#!/usr/bin/perl -w
use strict;

$|++;

$SIG{INT} = sub { &close_it_up };
$SIG{PIPE} = 'IGNORE';

my $mp3_in = shift || die "usage: $0 path/to/file.mp3\n"; #mp3 to play
from command line

my $pid;
my @options = (  '-slave',
                 '-really-quiet',
               );

##############################################################
my $pos; # time position in file....
my $i; # counter
print "$mp3_in\n";
$pid = open(MP, "| mplayer @options  '$mp3_in' >/dev/null 2>&1 ");
print "pid = $pid\n";
for ($i=0; $i<20; $i++) {
  # $pos = syswrite(MP, "get_time_pos\n");
  print MP "get_time_pos\n";
  # print "$pos\n";
  sleep(1);
}
syswrite(MP, "quit\n");


The syswrite to quite works fine, but the syswrite to get the time
position doesn't return anything useful. Printing to the filehandle
was just a test.

thanks for any help in advance.

jody
-- 
http://www.opendiscipleship.org/
http://www.RealizationSystems.com/ -- start communicating
http://www.GalacticSlacker.com/ -- read it and weep


More information about the Albuquerque-pm mailing list