remotly源脚本通过ssh [英] Source a script remotly via ssh

查看:167
本文介绍了remotly源脚本通过ssh的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要运行通过SSH远程程序需要一定的环境。因此,在执行程序之前,我源的特定文件建立了环境。如果我登录到本机直接,这是没有问题的,但是当我通过ssh执行命令

I want to run a remote program via ssh which requires a certain environment. Thus before executing the program I source a specific file building up the environment. If I'm logged onto the machine directly this is no problem but when I execute the command via ssh

#!/bin/bash
foo=`ssh user@host "source ~/script.sh; ~/run/program"`

我得到的指示该脚本没有正确来源错误。你知道我有什么,以获得来源的脚本,并在同一会话中执行的程序呢?

I get an error that indicates that the script was not sourced correctly. Do you know what I have to do in order to get the script sourced and the program executed in the same session?

编辑:
我用脚本导出LD_LIBRARY_PATH和可执行抱怨它无法找到共享对象文件。默认的shell是bash。 会话是明确的不正确的措辞。我的意思是'终端环境。

I'm exporting the LD_LIBRARY_PATH with the script and the executable is complaining that it cannot find the shared object file. The default shell is bash. 'Session' is definitive not the right wording. I meant 'terminal environment'.

推荐答案

感谢您所有的时间和帮助。我发现这个问题。如何执行远程程序的基本思想是从一开始就正确。当在机器上进行本地测试我的情况下,当前工作目录是不同的。出于某种原因,这个采购bash脚本时CWD是非常重要的。

Thank you for all your time and help. I found the issue. The basic idea of how to execute the remote program was right from the beginning. When testing my case locally on the machine, the current working directory was different. For some reason the cwd is important when sourcing this bash script.

这篇关于remotly源脚本通过ssh的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆