2
votes

I'm using node js and google's https://googleapis.dev/nodejs to launch the servers and im running a start up script curl "http://eve-robotics.com/release/EveAIO_setup.exe" --output Eve.exe and in the logs it says 2019/12/29 20:27:44 windows-startup-script-bat: 'curl' is not recognized as an internal or external command, and this only happens for 2012,2016 instances on the 2019 it works fine, if i cannot use this command for these instances is there another way to download this file from a start up script?

Update this is the command i am running for the start-up-script 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 and after it is done running as i see in the logs of the instance i connect to it and the error i get when i try to run plz.exe is "the system cannot find the file specified".

Update Now i am getting this error after passing a full path

2019/12/30 21:36:20 windows-startup-script-ps1: Invoke-WebRequest : Illegal characters in path. 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 windows-startup-script-ps1: char: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 : NotSpecified: (:) [Invoke-WebRequest], ArgumentE 2019/12/30 21:36:21 windows-startup-script-ps1: xception 2019/12/30 21:36:21 windows-startup-script-ps1: + FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.Co 2019/12/30 21:36:21 windows-startup-script-ps1: mmands.InvokeWebRequestCommand

this is the command i am using

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:\Users\browardboybrian\Desktop\plz.exe

1
Instead of using curl use PowerShell Invoke-WebRequest.John Hanley
I tried but it is not wokring it says it cannot find the file specifed when i use -OutFile Eve.exethrasher8939
Do you want to download the Eve exe file into the folder of a starting VM and execute it ? Is it just that ?Wojtek_B
What is the exact line that you are using for Invoke-WebRequest? What is the exact error message? Add this information to your question.John Hanley
If you are executing programs from a startup script, you should use full path names. You are using relative paths. For the powershell command, why are you adding all those headers? That is not your problem, but that is not necessary. Unless Invoke-WebRequest reported an error, you problem is that you are not specify the full path for the download and for the program launch.John Hanley

1 Answers

0
votes

If you're already running a node server script, the server could on get the file via http and save it as Eve.exe

Here is an example from Using Node.js to download files

// 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);
    });
  });
};