I want to remotely run a node.js script containing a shebang line through ssh, similarly as when running it locally.
myscript file:
#!/usr/bin/env node
var param = process.argv[2] || 'help';
//... other js code
When running locally on each host – e.g. myscript arg1 – it runs successfully. When running remotely on a "sister" node in a cluster (containing the same file and directory structure, including nodeand myscript):
ssh -o "PasswordAuthentication no" [email protected] /path/to/myscript arg1
I get /usr/bin/env: ‘node’: No such file or directory error.
Am I missing a ssh param / option?
Mode details: If I run
ssh -o "PasswordAuthentication no" [email protected] echo "hello"
It also works fine. Forgive me it this is obvious to you, I'm not an advanced Linux user, the ssh manual seemed a little bit overwhelming and tried a couple answers found here with no success:
nodeis installed the same on all nodes in the cluster?ssh -o "PasswordAuthentication no" [email protected] bash -c "/path/to/myscript arg1"nodeandmyscriptare installed in the same location; and no, bash -c "..." didn't get a different result.