如何在ssh命令行中使用环境模块? [英] How to use environment modules in a ssh command line?
问题描述
环境模块包用于动态修改用户环境( debian包 environment-modules
)
The Environment Modules package is used for dynamic modification of a user's environment (debian package environment-modules
).
我想从 ssh $ c $直接使用
模块
c>命令行。目的是能够在前端节点上执行的bash脚本中执行不同节点上的命令。我不想为每个不同的节点配置显式更新 PATH
和 LD_LIBRARY_PATH
环境变量。
I would like to use module
directly from a ssh
command line. The purpose is to be able to execute commands on different nodes from a bash script executed on a front node. I don't want to explicitly update PATH
and LD_LIBRARY_PATH
environment variables for each different node configuration.
当我直接连接到节点,然后从节点调用模块
时,显然可以工作:
When I directly connect to the node and then call module
from the node, it is obviously working:
jyvet> ssh mynode
jyvet@mynode> module load gcc-6.0
jyvet@mynode> gcc --version
gcc (GCC) 6.0.1
但以下方法失败:
jyvet> ssh mynode "module load gcc-6.0; gcc --version"
command not found: module
gcc-4.8 (Debian 4.8.4-1) 4.8.4
推荐答案
模块
$ c> /etc/profile.d/modules.sh 由 / etc / profile
(它在启动时设置环境变量)调用shell)
module
is initialized by /etc/profile.d/modules.sh
which is called by /etc/profile
(which sets the environment variables at startup of the shell).
ssh
命令执行shell是一个非交互式shell 并且既不调用 / etc / profile
,也不会读取配置文件。
The ssh
command execution shell is a non-interactive shell and does neither call /etc/profile
, nor read config files.
这是解决方案:
jyvet> ssh mynode "source /etc/profile; module load gcc-6.0; gcc --version"
gcc (GCC) 6.0.1
这篇关于如何在ssh命令行中使用环境模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!