Reputation: 41
Here I'm trying to run node file in AWS server with the ssh command through the shell script, where inside the shell file there is a command to run node file (node test.js)
Executing the below command, will run the shell file inside AWS server
ssh -i sample-test.pem ubuntu@ip 'bash -s' < my-folder/test.sh
test.sh file [Shell file]
node test.js
test.js file [Node file]
console.log("Venkatesh");
If I run the shell command directly inside the AWS server, node file runs perfectly. But if I run with the ssh command, it throws an error like this:
line 1: node: command not found
I have also tried from nodejs by using node-ssh package, same error occurs again.
How do I suppose to run a node file through shell script from ssh command?
Upvotes: 2
Views: 1867
Reputation: 41
Thanks to ROOT
Add the node path while running the node file. The response of which node
will be add to run the node file.
which node #FULL/PATH/TO/NODE
FULL/PATH/TO/NODE test.js
Upvotes: 1