Javascript 在Debian上连接EConRefused消息,但在Windows上工作
我编写了一些javascript将消息从XBMC委托给我的Dune mediaplayer。因此,我从windows开始,使用一个批处理文件来执行javascript,其中包含Node.js代码 start.bat:Javascript 在Debian上连接EConRefused消息,但在Windows上工作,javascript,linux,windows,node.js,Javascript,Linux,Windows,Node.js,我编写了一些javascript将消息从XBMC委托给我的Dune mediaplayer。因此,我从windows开始,使用一个批处理文件来执行javascript,其中包含Node.js代码 start.bat: @echo off node \Users\Flo\Desktop\file.js %1 file.js: var http = require("http"); var filepath = process.argv[2].substring(6); filepath = f
@echo off
node \Users\Flo\Desktop\file.js %1
file.js:
var http = require("http");
var filepath = process.argv[2].substring(6);
filepath = filepath.replace(/\\/g,"/");
var dcmd = "http://dune/cgi-bin/do?cmd=start_file_playback&media_url=storage_name:/" + filepath;
http.get(dcmd, function(res) {
console.log("Got response: " + res.statusCode);
var bodyarr = [];
res.on('data', function(chunk){
bodyarr.push(chunk);
});
res.on('end', function(){
console.log(bodyarr.join('').toString());
});
}).on('error', function(e) {
console.log("Got error: " + e.message);
});
使用此设置,一切都可以正常工作。
但现在我想用一个shell脚本在Raspbian系统上实现这一点
start.sh:
#!/bin/sh
nodejs /usr/local/bin/file.js $1
我总是会遇到这样的错误:连接
为什么?
谢谢你的帮助 dune应该解析到哪个主机?80端口监听的是什么?在哪个IP上?是我家局域网上的沙丘温API。ip为192.168.1.234。但我认为这并不重要,因为我可以在shell中使用curl命令执行get请求并获得xml响应。您是从Raspberry Pi发出curl请求的吗?是的。我的桌面上有Windows,树莓皮上有Raspbian。我正在做从ssh连接到pi的curl。