
Security News
Meet Socket at Black Hat Europe and BSides London 2025
Socket is heading to London! Stop by our booth or schedule a meeting to see what we've been working on.
machine-as-script
Advanced tools
Build a modified version of a machine that proxies its inputs from CLI arguments and/or -- opts.
$ npm install machine-as-script --save
#!/usr/bin/env node
var asScript = require('machine-as-script');
var MPMath = require('machinepack-math');
asScript(MPMath.add).exec({
success: function (sum){
console.log('Got result:', sum);
}
});
Now you can run your machine as a script and provide inputs as CLI opts:
$ node ./add-numbers.js --a=4 --b=5
# Got result: 9
Note that the machine definition you provide here doesn't have to come from an already-published machinepack-- it can be required locally from your project, or declared inline.
You can use the args input to accept serial CLI arguments:
asScript({
machine: MPMath.add,
args: ['a', 'b']
}).exec({
success: function (sum){
console.log('Got result:', sum);
}
});
Now you can use serial CLI arguments as inputs:
$ node ./add-numbers.js 2 3
# Got result: 5
MIT © Mike McNeil
FAQs
Run a machine as a command-line script.
The npm package machine-as-script receives a total of 4 weekly downloads. As such, machine-as-script popularity was classified as not popular.
We found that machine-as-script demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket is heading to London! Stop by our booth or schedule a meeting to see what we've been working on.

Security News
OWASP’s 2025 Top 10 introduces Software Supply Chain Failures as a new category, reflecting rising concern over dependency and build system risks.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.