3 # (the Shout library causes warnings if we use -w)
6 # Usage: yashout filename mountpoint [ port ]
8 # Copyright (c) 2003 Ivan Kohler
10 # This program is free software; you can redistribute it and/or modify it under
11 # the same terms as Perl itself.
14 use subs qw(daemonize);
17 #read options from commandline
18 my($filename, $mountpoint, $port) = @ARGV;
20 my $conn = new Shout (
22 port => $port || 8000,
26 name => 'Fonestream audio',
27 url => 'http://www.fonestream.com/',
29 description => 'The easiest way to webcast.',
33 $conn->connect or die "Failed to connect: ". $conn->error;
35 open(FILE,"<$filename") or die "Can't open $filename: $!";
37 daemonize(); #fork/disconnect so plex.pls will return to client
40 my( $buffer, $bytes ) = ( '', 0 );
41 while ( ( $bytes = read( FILE, $buffer, 4096 ) ) > 0 ) {
42 $conn->sendData( $buffer ) && next;
44 print STDERR "Error while sending: ", $conn->error, "\n";
53 chdir "/" or die "Can't chdir to /: $!";
54 open STDIN, '/dev/null' or die "Can't read /dev/null: $!";
55 defined(my $pid = fork) or die "Can't fork: $!";
57 #print "yashout started with pid $pid\n"; #logging to $log_file\n";
58 exit unless $pid_file;
59 #my $pidfh = new IO::File ">$pid_file" or exit;
60 #print $pidfh "$pid\n";
63 open STDOUT, '>/dev/null' or die "Can't write to /dev/null: $!";
64 setsid or die "Can't start a new session: $!";
65 open STDERR, '>&STDOUT' or die "Can't dup stdout: $!";
67 #$SIG{__DIE__} = \&_die;
68 #$SIG{__WARN__} = \&_logmsg;