0

My goal is to call an Octave(MATLAB) program on my EC2 instance from my Node/Express app and consume the results from that program (it will be in csv format) back in my Node app. I will pass a data file to the Octave program, and the length of the data file will be different each time I run my Node app. That's because my Node.js wrapper will take user input (start and end times), fetch data from an API, then I need to pass that data file to the MATLAB app for it to process.

I figured out how to connect to my EC2 instance using AWS SDK for Node's EC2InstanceConnect method. But now I can't figure out how to call the program on the instance, wait for the response, and then handle the resulting csv.

Since I know how to run the program when I'm SSH'd into my EC2 instance, I started thinking I need more of an SSH forwarding solution for this problem. But if there's a way to do it with the AWS SDK that would be better. I'm having a hard time finding examples online that are similar to my use case.

  • The most basic way, would be to execute your matlab in command mode (no gui) like any bash shell script from [nodejs](https://stackoverflow.com/questions/4443597/node-js-execute-system-command-synchronously). Obviously, this only makes sense if this is short running command. For long running command more elaborate solution would be needed. – Marcin Jun 06 '20 at 00:18
  • @Marcin I updated my question with more information about the input I will be passing to the MATLAB program. Since the data input will be of variable length, it could take some time for MATLAB to process it. – Vanessa Bell Jun 06 '20 at 00:24
  • How often will you be making this call? – f.ardelian Jun 06 '20 at 09:46
  • @f.ardelian at first we’ll only have a max of 4 users accessing the node app at a time to specify the data input they want to run through the MATLAB analysis. On a given day I imagine one user would run the analysis 10-20 times. So traffic will be extremely low. – Vanessa Bell Jun 07 '20 at 02:54
  • You could write another very simple HTTP server app and run it on the Matlab EC2 instance. That app would listen for incoming HTTP, run the Octave app, capture its output and return that output to the client which initiated the HTTP call. – f.ardelian Jun 07 '20 at 07:28

0 Answers0