[slim] Re: Using the slimserver cli from perl

2005-07-21 Thread Dan Sully

* max.spicer shaped the electrons to say...


It turns out that saying
print <$s>;
generally causes the script to hang, whereas saying
my $answer = <$s>;
print $answer;
works every time.  Could anyone enlighten me as to why this is?


print operates in list context - and reading from a filehandle, like <$s> is
list context. So it blocks, expecting to read more.

Retrieving data in scalar context, such as my $answer = <$s> only pulls one 
line.*

Hope that helps.

* - Really the input record separator: $/ which by default is "\n"

-D
--
 the auto mechanic told me there was something wrong with my rear 
differential.
I told him I never took calculus.
___
Discuss mailing list
Discuss@lists.slimdevices.com
http://lists.slimdevices.com/lists/listinfo/discuss


[slim] Re: Using the slimserver cli from perl

2005-07-21 Thread max . spicer

It turns out that saying
print <$s>;
generally causes the script to hang, whereas saying
my $answer = <$s>;
print $answer;
works every time.  Could anyone enlighten me as to why this is?

Thanks for the help anyway!

Max

max.spicer Wrote: 
> Thanks, I'll have a play with them tomorrow.  They look as if they're
> doing exactly what I'm trying to do at one stage, and in the same way
> too.  Hmm...
> 
> Max


-- 
max.spicer

The wild things roared their terrible roars and gnashed their terrible
teeth
and rolled their terrible eyes and showed their terrible claws
but Max stepped into his private boat and waved good-bye
___
Discuss mailing list
Discuss@lists.slimdevices.com
http://lists.slimdevices.com/lists/listinfo/discuss


[slim] Re: Using the slimserver cli from perl

2005-07-18 Thread max . spicer

Actually, I already had done.  My last posted attempt is a reworking of
that very script.  :-)  Have you ever tried printing $response?  It
generally doesn't work for me.  Don't waste any time on it though -
I'll have a closer look at things tomorrow.

You don't need $socket->autoflush (1); any more, by the way.  From
cpan: As of VERSION 1.18 all IO::Socket objects have autoflush turned
on by default. This was not the case with earlier releases.

Max

jth Wrote: 
> Shameless plug: see also the slim_cli.pl script here -
> 
> http://ultratrendy.com:31888/slim/


-- 
max.spicer

The wild things roared their terrible roars and gnashed their terrible
teeth
and rolled their terrible eyes and showed their terrible claws
but Max stepped into his private boat and waved good-bye
___
Discuss mailing list
Discuss@lists.slimdevices.com
http://lists.slimdevices.com/lists/listinfo/discuss


[slim] Re: Using the slimserver cli from perl

2005-07-18 Thread max . spicer

Thanks, I'll have a play with them tomorrow.  They look as if they're
doing exactly what I'm trying to do at one stage, and in the same way
too.  Hmm...

Max

mherger Wrote: 
> Max
> 
> > Okay, I've now got the following, but am still struggling to read
> > responses.  The current <$s> is an optimistic attempt that
> occasionally
> > works, but generally just makes the script hang after doing the
> pause.
> 
> Have a look at some of Felix Müller's scripts (eg. the FollowMe.pl
> http://www.gwendesign.ch/slimserver/src/followme01.pl) - I've always
> used  
> one of these to copy the communication part from. And it has worked for
> 
> me, too.
> 
> -- 
> 
> Michael
> 
> ---
> Help translate SlimServer by using the
> StringEditor Plugin (http://www.herger.net/slim/)


-- 
max.spicer

The wild things roared their terrible roars and gnashed their terrible
teeth
and rolled their terrible eyes and showed their terrible claws
but Max stepped into his private boat and waved good-bye
___
Discuss mailing list
Discuss@lists.slimdevices.com
http://lists.slimdevices.com/lists/listinfo/discuss


[slim] Re: Using the slimserver cli from perl

2005-07-17 Thread jth

Shameless plug: see also the slim_cli.pl script here -

http://ultratrendy.com:31888/slim/


-- 
jth
___
Discuss mailing list
Discuss@lists.slimdevices.com
http://lists.slimdevices.com/lists/listinfo/discuss


Re: [slim] Re: Using the slimserver cli from perl

2005-07-17 Thread Michael Herger

Max


Okay, I've now got the following, but am still struggling to read
responses.  The current <$s> is an optimistic attempt that occasionally
works, but generally just makes the script hang after doing the pause.


Have a look at some of Felix Müller's scripts (eg. the FollowMe.pl
http://www.gwendesign.ch/slimserver/src/followme01.pl) - I've always used  
one of these to copy the communication part from. And it has worked for  
me, too.


--

Michael

---
Help translate SlimServer by using the
StringEditor Plugin (http://www.herger.net/slim/)
___
Discuss mailing list
Discuss@lists.slimdevices.com
http://lists.slimdevices.com/lists/listinfo/discuss


[slim] Re: Using the slimserver cli from perl

2005-07-17 Thread max . spicer

Okay, I've now got the following, but am still struggling to read
responses.  The current <$s> is an optimistic attempt that occasionally
works, but generally just makes the script hang after doing the pause.

#!/usr/bin/perl -w
use strict;
use IO::Socket;

my $player = '00%3A04%3A20%3A05%3Aa9%3A87';

my $s = new IO::Socket::INET (PeerAddr => 'localhost',
PeerPort => 9023,
Proto=> 'tcp',
Type => SOCK_STREAM)
or die 'Couldn\'t connect to server';

$s->autoflush(1);

print $s "$player pause\n";
print $s "exit\n";
print <$s>;

close $s;


Thanks,

Max

Dan Sully Wrote: 
> Just use IO::Socket instead of Net::Telnet.


-- 
max.spicer

The wild things roared their terrible roars and gnashed their terrible
teeth
and rolled their terrible eyes and showed their terrible claws
but Max stepped into his private boat and waved good-bye
___
Discuss mailing list
Discuss@lists.slimdevices.com
http://lists.slimdevices.com/lists/listinfo/discuss


[slim] Re: Using the slimserver cli from perl

2005-07-17 Thread Dan Sully

* max.spicer shaped the electrons to say...


As part of an attempt to refresh my rusty Perl knowledge, I'm trying to
do some scripting using the slimserver cli.  For now, I'm  just trying
to issue some queries.  I'm currently using Net::Telnet, but aren't
sure if this is the best thing to be doing.  My current attempts aren't
going well as I don't seem able to set the prompt properly.  As a
result, my script never gets the responses from the cli.  Here's my
first attempt.  This successfully pauses the player but never prints
anything.  Could anyone offer any pointers?


Just use IO::Socket instead of Net::Telnet.

-D
--
It does not do to leave a live Dragon out of your calculations..
___
Discuss mailing list
Discuss@lists.slimdevices.com
http://lists.slimdevices.com/lists/listinfo/discuss