Roland0 wrote:
> My sexpect spawn backgrounds itself - maybe because I spawn a shell.
> You should do a "wait" after the "close", otherwise sexpect will hang (I
> guess this is why you kill it?)
> Haven't found a way to suppress the output, so I just redirect stdout to
> /dev/null
>
Yes, I think spawning a shell is the difference though manually
backgrounding it in my test script worked ok, just took me a few minutes
to figure out what was going on since I didn't think backgrounding was
necessary.
I was killing the port 9000 sexpect process and then respawning it at
the top of the loop as an ugly way of clearing the buffer.
>
> But doesn't this just always process the first track in the playlist
> (which isn't necessarily the one playing) ?
>
No, index 0 is the currently playing song if you use the dash in the
query - from the cli page:
Code:
--------------------
Set the parameter to "-" to get the playlist data starting from the current
song.
--------------------
>
> btw, if you use wget to post, you don't need netcat, the second sexpect
> spawn and the matching sexpect expect/_outs - simply put the result JSON
> into a variable.
The busybox wget doesn't do post. Haha, I know, get a different version
that does, and any sane person would, but I seem to be irrationally hung
up on not wanting to bring in extra tools, even though I have to for some
things.
Just a few minutes ago I finally figured out how to get the json data just
using the busybox nc, that was driving me crazy. I couldn't understand
why it was just exiting without returning anything. It's the sleep .1
that made all the difference.
Here's the little test script I used:
Code:
--------------------
#!/bin/sh
post=$(cat <<'END_HEREDOC'
POST /jsonrpc.js HTTP/1.1
HOST: 192.168.1.201:9000
Content-Type: application/json; charset=utf-8
Content-Length: 97
{"id":1,"method":"slim.request","params":["b8:27:eb:94:ae:63",["status","-","1","tags:acgltys"]]}
END_HEREDOC
)
(echo -e "$post"; sleep .1) | nc 192.168.1.201 9000 | tail --line=+7 > json.txt
--------------------
So now I'm thinking about trying the log watching method so I can detect
newsong events and retrieve the json with just busybox builtins.
------------------------------------------------------------------------
sodface's Profile: http://forums.slimdevices.com/member.php?userid=19057
View this thread: http://forums.slimdevices.com/showthread.php?t=109694
_______________________________________________
unix mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/unix