0

I have a deploy script that I want to run from a remote server, if I connect to the server and command manually it works fine:

ssh root@server cd /some-deploy-folder node do-something.js 

But if I try to do the same by passing it into a single command to ssh:

ssh -t root@localhost <<EOF cd /some-deploy-folder node do-something.js exit EOF 

Bash is unable to find the node command reporting node: command not found

Is there some reason that passing the EOL commands directly into ssh is not correctly setting up the environment?

1 Answer 1

1

The problem is that when you send the command and not directly being logged in the shell is a non-interactive one and you don't have the same environment, you can read more about this on:

https://askubuntu.com/questions/698957/ssh-into-a-machine-and-then-launch-an-interactive-command-line-program

Here is more info about the type of shells:

https://unix.stackexchange.com/questions/50665/what-is-the-difference-between-interactive-shells-login-shells-non-login-shell

https://unix.stackexchange.com/questions/38175/difference-between-login-shell-and-non-login-shell

1
  • 1
    Thanks, problem resolved by starting bash in interactive mode i.e. ssh root@server "bash -i -c 'node /some-deploy-folder/do-something.js" Commented Jul 27, 2017 at 13:32

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.