#!/usr/bin/perl #perl shoutcast stats # by Rayeh #To run use: #perl scastperl host port my ($host,$port) = @ARGV; use IO::Socket; my $sock = IO::Socket::INET->new( PeerAddr => $host, PeerPort => $port, Proto => 'tcp', ) or die "Couldn't connect! $!"; print $sock "GET /7.html HTTP/1.1\r\nUser-Agent: Mozilla\r\n\r\n"; while ( $temp = <$sock> ) { chomp($temp); $temp =~ s/HTTP\/1.0 200 OK/./; $temp =~ s/content-type:text\/html/./; $temp =~ s/<\/head>//; $temp =~ s/<\/body><\/html>//; if ($temp =~ /.*\,.*/) { @data = split(",",$temp); $bandwidth = (($data[5]*$data[0])/1024)."Mbits"; if ($data[1] == 1) { $connected = "connected"; } else { $connected = "not connected"; } print "DSP $connected and playing $data[6] .\n"; print "$data[0] listeners out of $data[3] at $data[5] wasting $bandwidth of bandwidth.\n"; print "Tune in at http:\/\/".$host.":".$port."/listen.pls\n"; } } close($socket);