SSH script does not have access to full path variable
Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
0
down vote
favorite
When I ssh
into host and echo $PATH
:
$ ssh my@host
$ echo $PATH
I get a different value for $PATH
than when I run a script locally:
ssh my@host '
echo $PATH;'
Any idea why?
NOTE: It seems I don't get the full path variable when ssh
ing from a script versus [other] CLI.
linux ssh
add a comment |Â
up vote
0
down vote
favorite
When I ssh
into host and echo $PATH
:
$ ssh my@host
$ echo $PATH
I get a different value for $PATH
than when I run a script locally:
ssh my@host '
echo $PATH;'
Any idea why?
NOTE: It seems I don't get the full path variable when ssh
ing from a script versus [other] CLI.
linux ssh
1
ssh opens login shell and what happens depends on the shell you use and your setup. For example if you usebash
only/etc/profile
is processed.
â Arkadiusz Drabczyk
Jul 19 at 18:19
show us, don't make us guess. What was the output?
â ctrl-alt-delor
Jul 19 at 18:56
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
When I ssh
into host and echo $PATH
:
$ ssh my@host
$ echo $PATH
I get a different value for $PATH
than when I run a script locally:
ssh my@host '
echo $PATH;'
Any idea why?
NOTE: It seems I don't get the full path variable when ssh
ing from a script versus [other] CLI.
linux ssh
When I ssh
into host and echo $PATH
:
$ ssh my@host
$ echo $PATH
I get a different value for $PATH
than when I run a script locally:
ssh my@host '
echo $PATH;'
Any idea why?
NOTE: It seems I don't get the full path variable when ssh
ing from a script versus [other] CLI.
linux ssh
edited Jul 19 at 19:26
slmâ¦
232k65479649
232k65479649
asked Jul 19 at 18:14
the_prole
1113
1113
1
ssh opens login shell and what happens depends on the shell you use and your setup. For example if you usebash
only/etc/profile
is processed.
â Arkadiusz Drabczyk
Jul 19 at 18:19
show us, don't make us guess. What was the output?
â ctrl-alt-delor
Jul 19 at 18:56
add a comment |Â
1
ssh opens login shell and what happens depends on the shell you use and your setup. For example if you usebash
only/etc/profile
is processed.
â Arkadiusz Drabczyk
Jul 19 at 18:19
show us, don't make us guess. What was the output?
â ctrl-alt-delor
Jul 19 at 18:56
1
1
ssh opens login shell and what happens depends on the shell you use and your setup. For example if you use
bash
only /etc/profile
is processed.â Arkadiusz Drabczyk
Jul 19 at 18:19
ssh opens login shell and what happens depends on the shell you use and your setup. For example if you use
bash
only /etc/profile
is processed.â Arkadiusz Drabczyk
Jul 19 at 18:19
show us, don't make us guess. What was the output?
â ctrl-alt-delor
Jul 19 at 18:56
show us, don't make us guess. What was the output?
â ctrl-alt-delor
Jul 19 at 18:56
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
0
down vote
This is due to the fact that when you run a command through ssh (ssh user@host 'command'
) it opens a non-login shell. An excellent breakdown of the differences between a login shell and a non-login shell can be found at this question. Essentially, what is causing you issue is that when you run the command through ssh your ~/.bash_profile
is not sourced, meaning any modifications to the path it makes will not be available.
The solution is to either move these into your ~/.bashrc
, which is sourced on opening a non-login shell, or as you found out, sourcing your .bash_profile
directly in the script.
add a comment |Â
up vote
0
down vote
Adding this line to bash script worked
source ~/.bash_profile
source
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
This is due to the fact that when you run a command through ssh (ssh user@host 'command'
) it opens a non-login shell. An excellent breakdown of the differences between a login shell and a non-login shell can be found at this question. Essentially, what is causing you issue is that when you run the command through ssh your ~/.bash_profile
is not sourced, meaning any modifications to the path it makes will not be available.
The solution is to either move these into your ~/.bashrc
, which is sourced on opening a non-login shell, or as you found out, sourcing your .bash_profile
directly in the script.
add a comment |Â
up vote
0
down vote
This is due to the fact that when you run a command through ssh (ssh user@host 'command'
) it opens a non-login shell. An excellent breakdown of the differences between a login shell and a non-login shell can be found at this question. Essentially, what is causing you issue is that when you run the command through ssh your ~/.bash_profile
is not sourced, meaning any modifications to the path it makes will not be available.
The solution is to either move these into your ~/.bashrc
, which is sourced on opening a non-login shell, or as you found out, sourcing your .bash_profile
directly in the script.
add a comment |Â
up vote
0
down vote
up vote
0
down vote
This is due to the fact that when you run a command through ssh (ssh user@host 'command'
) it opens a non-login shell. An excellent breakdown of the differences between a login shell and a non-login shell can be found at this question. Essentially, what is causing you issue is that when you run the command through ssh your ~/.bash_profile
is not sourced, meaning any modifications to the path it makes will not be available.
The solution is to either move these into your ~/.bashrc
, which is sourced on opening a non-login shell, or as you found out, sourcing your .bash_profile
directly in the script.
This is due to the fact that when you run a command through ssh (ssh user@host 'command'
) it opens a non-login shell. An excellent breakdown of the differences between a login shell and a non-login shell can be found at this question. Essentially, what is causing you issue is that when you run the command through ssh your ~/.bash_profile
is not sourced, meaning any modifications to the path it makes will not be available.
The solution is to either move these into your ~/.bashrc
, which is sourced on opening a non-login shell, or as you found out, sourcing your .bash_profile
directly in the script.
answered Jul 19 at 18:44
Thegs
31516
31516
add a comment |Â
add a comment |Â
up vote
0
down vote
Adding this line to bash script worked
source ~/.bash_profile
source
add a comment |Â
up vote
0
down vote
Adding this line to bash script worked
source ~/.bash_profile
source
add a comment |Â
up vote
0
down vote
up vote
0
down vote
Adding this line to bash script worked
source ~/.bash_profile
source
Adding this line to bash script worked
source ~/.bash_profile
source
edited Jul 19 at 19:20
slmâ¦
232k65479649
232k65479649
answered Jul 19 at 18:30
the_prole
1113
1113
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f457275%2fssh-script-does-not-have-access-to-full-path-variable%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
ssh opens login shell and what happens depends on the shell you use and your setup. For example if you use
bash
only/etc/profile
is processed.â Arkadiusz Drabczyk
Jul 19 at 18:19
show us, don't make us guess. What was the output?
â ctrl-alt-delor
Jul 19 at 18:56