2012,2016 GCE Windows服务器是否已经安装了CURL?



我正在使用节点js和google的 https://googleapis.dev/nodejs 来启动服务器并运行启动脚本curl "http://eve-robotics.com/release/EveAIO_setup.exe" --output Eve.exe在日志中它说 2019/12/29 20:27:44 Windows-startup-script-bat:"curl"不被识别为内部或外部命令,这仅适用于 2012,2016 上的 2019实例它工作正常,如果我不能对这些实例使用此命令,是否有另一种方法可以从启动脚本下载此文件?

更新这是我为启动脚本运行的命令Invoke-WebRequest -Uri "http://eve-robotics.com/release/EveAIO_setup.exe" -Headers @{"Upgrade-Insecure-Requests"="1"; "User-Agent"="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36"; "Accept"="text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.9"; "Accept-Encoding"="gzip, deflate"; "Accept-Language"="en-US,en;q=0.9";} -OutFile plz.exe,在它完成运行后,正如我在连接到它的实例的日志中看到的那样,当我尝试运行时.exe我遇到的错误是"系统找不到指定的文件"。

现在更新,我在传递完整路径后收到此错误

2019/12/30 21:36:20 Windows-startup-script-ps1:调用WebRequest :路径中的非法字符。 2019/12/30 21:36:20 Windows-startup-script-ps1: at C:\Windows\TEMP\metadata-scripts903292515\windows-startup-script-ps1.ps1:1 2019/12/30 21:36:20 窗口启动脚本-PS1:字符:1 2019/12/30 21:36:20 Windows-startup-script-ps1: + Invoke-WebRequest -Uri "http://eve-robotics.com/release/EveAIO_setup.... 2019/12/30 21:36:21 Windows-Startup-script-ps1: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2019/12/30 21:36:21 Windows-startup-script-ps1: + CategoryInfo : NotSpecific: (:) [Invoke-WebRequest], ArgumentE 2019/12/30 21:36:21 Windows-Startup-script-PS1: Xception 2019/12/30 21:36:21 Windows-startup-script-ps1: + FullQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.Co 2019/12/30 21:36:21 Windows-startup-script-ps1:mmands。InvokeWebRequestCommand

这是我正在使用的命令

Invoke-WebRequest -Uri "http://eve-robotics.com/release/EveAIO_setup.exe" -Headers @{"Upgrade-Insecure-Requests"="1"; "User-Agent"="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36"; "Accept"="text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.9"; "Accept-Encoding"="gzip, deflate"; "Accept-Language"="en-US,en;q=0.9";} -OutFile C:UsersbrowardboybrianDesktopplz.exe

如果您已经在运行节点服务器脚本,服务器可以通过 http 获取文件并将其另存为Eve.exe

下面是使用 Node.js 下载文件的示例

// Dependencies
var fs = require('fs');
var url = require('url');
var http = require('http');
var exec = require('child_process').exec;
// App variables
var file_url = 'http://upload.wikimedia.org/wikipedia/commons/4/4f/Big%26Small_edit_1.jpg';
var DOWNLOAD_DIR = './downloads/';
// We will be downloading the files to a directory, so make sure it's there
// This step is not required if you have manually created the directory
var mkdir = 'mkdir -p ' + DOWNLOAD_DIR;
var child = exec(mkdir, function(err, stdout, stderr) {
if (err) throw err;
else download_file_httpget(file_url);
});
// Function for downloading file using HTTP.get
var download_file_httpget = function(file_url) {
var options = {
host: url.parse(file_url).host,
port: 80,
path: url.parse(file_url).pathname
};
var file_name = url.parse(file_url).pathname.split('/').pop();
var file = fs.createWriteStream(DOWNLOAD_DIR + file_name);
http.get(options, function(res) {
res.on('data', function(data) {
file.write(data);
}).on('end', function() {
file.end();
console.log(file_name + ' downloaded to ' + DOWNLOAD_DIR);
});
});
};

最新更新