2

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.

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

1 Answer 1

0

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

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.