Different behaviour of script locally and over ssh

Posted by neorg on Server Fault See other posts from Server Fault or by neorg
Published on 2012-10-01T09:09:41Z Indexed on 2012/10/01 9:39 UTC
Read the original article Hit count: 146

Filed under:
|
|
|

I have a script on a server-A

Script-A

#!/bin/bash -l
echo "script-A.sh" | change-environment.sh

When I ssh onto server-A and execute it, it works fine. However, when I

ssh user@server-A ./script-A.sh

Script-A executes, but throws an undefined variable error in change-environment.sh.

change-environment.sh runs in the c shell(I have no control over the script so the method I have used is about the only way I can use it), but everything else is in bash.

Had found a similar question at I can run a script locally, but cannot do "ssh HOSTNAME /path/to/script.sh". However, there was no solution to the issue and it was a year old.

© Server Fault or respective owner

Related posts about linux

Related posts about bash