On 10/8/06, Niss <[EMAIL PROTECTED]> wrote:

Many thanks for that (I should have looked harder).

I can use the CLI interactively by telnet to the host/port 9090 and run
a command like  "<playerid>  power ?" and see the response.

But how can I do this from a bash script? Is there a UNIX command I can
use to send the  CLI command to Slimserver and read the reply?

Thanks for any pointers.



Use expect.

#!/usr/bin/expect
set timeout 3
spawn -noecho /bin/bash
expect -re "$ "
send "telnet myserver:9090\n"
expect -re "Escape character"
send "player power ?\n"
set results $expect_out(buffer)
if {$result -re "1"} then {
    send "player power off\n"
    expect "off"
    send "exit\n"
    expect eof
} else {
    send "exit\n"
    expect eof
}

That ought to get you started -- I'm probably not remembering the right syntax for the regular _expression_ in the if statement, so google how to do those.

--
"I spent all me tin with the ladies drinking gin,
So across the Western ocean I must wander" -- traditional
_______________________________________________
discuss mailing list
[email protected]
http://lists.slimdevices.com/lists/listinfo/discuss

Reply via email to