PDA

View Full Version : Command Line



Kurt
2006-07-26, 11:35
Is there a way of just writing a simple batch file using the command line that would start a playlist in shuffle mode, etc?

I've been reading the documentation and it mentions using telnet to do an interactive session, but I really don't need this. I just want to pass simple command sets from batch files on a desktop.

I can see this of being some use to start one's favorite playlists, shut off the player, etc, without looking for the remote or starting the web interface.

radish
2006-07-26, 12:54
Don't know about doing it purely in a batch file, but if you install perl you can certainly use that. This is what I use to trigger a rescan:



use IO::Socket;

$server="squidward";
$port=9090;

print "Connecting to SlimServer at ".$server.":".$port."...\n";

$remote = IO::Socket::INET->new(
Proto => "tcp",
PeerAddr => $server,
PeerPort => $port,
)
or die "ERROR: Cannot connect to SlimServer";

$remote->autoflush(1);

print $remote "rescan\n";

$response = <$remote>;
$response eq "rescan\n" || die "ERROR: Bad response from SlimServer : $response\n";

print $remote "exit\n";
close $remote;

print "SlimServer is rescanning the music library\n";
exit;

Throw that in a .pl file and you can call it from a batchfile or just by double clicking.

Kurt
2006-07-27, 08:05
With a perl script could you pass multiple SB commands in one script, say playlist clear, then playlist shuffle on or off, playlist play, etc?

radish
2006-07-27, 10:35
With a perl script could you pass multiple SB commands in one script, say playlist clear, then playlist shuffle on or off, playlist play, etc?
Sure - the simplest way would just be to duplicate and edit the print $remote... and $response=... lines.

Kurt
2006-07-27, 10:48
Cool stuff. My perl's a bit rusty (probably 8 years ago) but I'll give it a try. Thanks.

Just one more quick one. Where would I download an interpreter?

Kurt
2006-07-27, 13:18
Cool stuff. My perl's a bit rusty (probably 8 years ago) but I'll give it a try. Thanks.

Just one more quick one. Where would I download an interpreter?

Please ignore previous. Got ActiveState installed. Scripts running great. Thanks!