0

I m working on hp Unix box. I m trying to execute remote script through ssh. My target script uses environment 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.

2
  • 1
    Can you show us at least a portion of your script ? Commented Jun 29, 2011 at 14:55
  • This is how i m assigning value: db_user=$ASMM_INSTALL_DB_USER db_pwd=$ASMM_INSTALL_DB_PASSWORD db_instance=$ASMM_INSTALL_DB_INSTANCE And here i m using them set -A res `sqlplus -s $db_user/$db_pwd@$db_instance <<ENDOFSQL Commented Jun 29, 2011 at 14:58

1 Answer 1

1

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 the PermitUserEnvironment option in sshd_config(5).

Finally, you can change the script to take command-line arguments instead of read its parameters from the environment.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the reponse.. ~/.ssh/environment did not work, finally i passed arguments. But now i am facing another problem.My script is trying to connect sqlplus. Though all paramerets are correct, it throwing below error message ERROR: The SQL Plus command execution failed! Error code: 1 On remote script i m using set -A res `sqlplus -s $db_user/$db_pwd@$db_instance <<ENDOFSQL command to connect. Any idea why i m getting this error. Thanks.
Looks like an error message from the SQL Plus command itself; and a cryptic one, too. I've no idea what that command even is, so I can't help you out.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.