使用bash将json命令发送到boxeebox

时间:2012-06-03 17:25:59

标签: json-rpc

我正在尝试让我的callerid脚本向我的boxee box连接电视发送通知。我的脚本在我的几台计算机上使用mgetty和notify-send工作。

这是我的cidscript.sh,由mgetty

触发
#!/bin/sh

# send message to computer
ssh -o ConnectTimeout=10 mrplow@192.168.1.10 "DISPLAY=:0 notify-send 'Phone call from...      $CALLER_NAME      $CALLER_ID'" &
sleep 0.2
ssh -o ConnectTimeout=10 christine@192.168.1.3 "DISPLAY=:0 notify-send 'Phone call from...      $CALLER_NAME      $CALLER_ID'" &
sleep 0.2
ssh -o ConnectTimeout=10 mrplow@192.168.1.120 "DISPLAY=:0 notify-send 'Phone call from...      $CALLER_NAME      $CALLER_ID'" &
sleep 0.2
su mrplow -c "DISPLAY=:0.0 notify-send 'Phone call from...      $CALLER_NAME      $CALLER_ID'" &
sleep 5

# update logs
echo `date +"%F %a %r"`"|$CALLER_ID|$CALLER_NAME" >> /home/mrplow/answering_machine/logs/incoming-calls.log
scp -o ConnectTimeout=10 /home/mrplow/answering_machine/logs/incoming-calls.log christine@192.168.1.3:/home/christine/Desktop/incoming-calls.log

sleep 0.2

exit 1

我认为json rpc将是实现这一目标的唯一途径 我已设法远程登录到原始端口9090上的boxee框,然后配对我的设备

所以脚本需要发送连接命令

{"jsonrpc": "2.0", "method": "Device.Connect", "params":{"deviceid": "############"}, "id": 1}

然后是实际通知

{"jsonrpc": "2.0", "method": "GUI.NotificationShow", "params":{"msg" : "Phone call from...      $CALLER_NAME      $CALLER_ID"}, "id": 1}

我试过这个无济于事

curl -d '{"jsonrpc": "2.0", "method": "Device.Connect", "params":{"deviceid": "00112fa696c9"}, "id": 1}\
{"jsonrpc": "2.0", "method": "GUI.NotificationShow", "params":{"msg" : "test"}, "id": 1}' -i 192.168.1.6 9090

1 个答案:

答案 0 :(得分:0)

想通了......

echo { \"jsonrpc\": \"2.0\", \"method\": \"Device.Connect\", \"params\":{\"deviceid\": \"############\"}, \"id\": 1}\
{ \"jsonrpc\": \"2.0\", \"method\": \"GUI.NotificationShow\", \"params\":{\"msg\" : \"Phone call from...      $CALLER_NAME      $CALLER_ID\"}, \"id\": 1 } | telnet 192.168.1.6 9090 &> /dev/null