Unable to get environment variable values while executing script on remote server
I m working on hp Unix box. I m trying to execute remote script through ssh. My target script uses environmen开发者_JAVA百科t variables value internally. When i do manually ssh and do echo $(env_vairable_name), it prints the value. But when i execute script remotely, it does not get env variable value. I m trying blow command to execute remote script. ssh remote_user@remote_hostname "~/my_script_on_remote.ksh". Please advice.
Thanks.
You should set the environment variables in the startup file for the Korn shell on the remote host.
You can also use the file ~/.ssh/environment
, but ssh(1)
warns (emphasis added):
Additionally,
ssh
reads~/.ssh/environment
, and adds lines of the format “VARNAME=value
” to the environment if the file exists and users are allowed to change their environment. For more information, see thePermitUserEnvironment
option insshd_config(5)
.
Finally, you can change the script to take command-line arguments instead of read its parameters from the environment.
精彩评论