On Unix, you have the option to add special command to the first line of the JavaScript file telling the operating system how to run the script:
#!/usr/bin/env node
To make the script executable change execute mode:
chmod u+x myscript.js
Now it can be run on its own:
./myscript.js arg1 arg2 ...
We can start script even with STRRMTCMD command from 5250 terminal:
STRRMTCMD './myscript.js arg1 arg2 ....'
Advanced Tip
Shown example is for Green Screens Terminal Client. When running web Terminal, remote command is not possible because of browser sandbox, but there is a solution.
It is possible to create Node.JS service running on local computer which will start WebSocket service. When web terminal receives STRTMTCMD, we can connect to local service with browser side WebSocket client and forward calls to Node.JS which will start required command.
Find more about that option in our blog...