My environment configuration is different when I execute commands using ssh string parameter (non-interactive ssh) instead of running them by hand in server (interractive ssh)?

Example: When I run ssh <user@servername> "echo \$SGE_ROOT", I get empty string. When I connect to my server ssh <user@servername> and run command echo $SGE_ROOT I get /opt/gridengine.

I guess some kind of profile script is not executed. Is it possible to find out which script and run it through non-interactive ssh to make environment configuration identical?

Server uses CentOS 6.6.

  • It seems like dublicate question. My more specific question is How to find out which scripts are not executed in non-interactive ssh? – niekas Sep 9 '15 at 11:10
  • Running ssh <user@servername> "source /etc/profile; echo \$SGE_ROOT" worked. – niekas Sep 9 '15 at 11:21
  • 1
    please, write the solution into the answer field to help others. – Jakuje Sep 9 '15 at 11:41

It seems that none of profile or bash scripts are executed when using non-interactive ssh. So I had to call them explicitly:

ssh <user@servername> "source /etc/profile; echo \$SGE_ROOT"

Also I had to comment this line in ~/.bashrc file:

# If not running interactively, don't do anything
[ -z "$PS1" ] && return

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.