为非交互式Shell正确获取.bashrc的方法 [英] Correct way to source .bashrc for non-interactive shell

查看:118
本文介绍了为非交互式Shell正确获取.bashrc的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试解决问题,以便能够在多个节点上运行openmpi.

I have been trying to resolve problems to be able to run openmpi on multiple nodes.

最初,我无法通过openmpi会话从 .bashrc 文件更新 $ PATH $ LD_LIBRARY_PATH 变量时遇到问题,所以我手动进行了操作添加了-前缀/path/to/openmpi 来解决此问题.

Initially I had a problem with $PATH and $LD_LIBRARY_PATH variables not being updated from .bashrc file by openmpi session, so I manually added --prefix /path/to/openmpi to resolve this issue.

结果是,即使anaconda路径变量也没有被加载.因此,最终我需要从我的主目录获取〜/.bashrc 文件.我怎样才能做到这一点?有人可以帮我吗?

Turns out that even the anaconda path variables are not being loaded as well. So ultimately I need ~/.bashrc file to be sourced from my home directory. How can I do that? Can anyone help me out please?

更新01:

我写了一个简单的shell脚本来检查python的版本

I wrote a simple shell script to check the version of python

python --version

并尝试使用openmpi在本地以及远程计算机上运行它,如下所示:

and tried to run it with openmpi on local as well as remote machine as follows:

mpirun --prefix /home/usama/.openmpi --hostfile hosts -np 4 bash script

它返回

Python 2.7.12
Python 3.6.8 :: Anaconda, Inc.
Python 3.6.8 :: Anaconda, Inc.
Python 2.7.12

确认我怀疑openmpi为运行远程进程所做的任何事情都不会从〜/.bashrc文件调用/设置适当的环境变量.使用多节点openmpi的人有任何帮助吗?

Confirming my suspicion that whatever openmpi is doing to run remote processes doesn't invoke / set proper environment variables from the ~/.bashrc file. Any help from someone who has worked with multi-node openmpi?

更新02:

一个简单的ssh环境grep告诉我,我的环境变量未更新,这可能是问题的原因.(我什至尝试将其设置为〜/.ssh/environment文件)

A simple ssh environment grep tell me that my environment variables are not updated which might be the cause of the problem. (I have even tried to set it up in ~/.ssh/environment file)

$ ssh remote-node env | grep -i path

似乎仅使用基本路径设置来加载/etc/environment文件.我该如何纠正?

It seems to be loading only the /etc/environment file with only basic paths setup. How to I rectify this?

推荐答案

也许您应该这样运行.我想.两种方法可以帮助您!

maybe you should run like this.I guess. two ways help you!

第一:

mpirun --prefix /home/usama/.openmpi --hostfile hosts -np 4 . ~/.bashrc && bash script

秒:

## 1. add this line to the script
. ~/.bashrc

## 2. run command as you do
mpirun --prefix /home/usama/.openmpi --hostfile hosts -np 4 bash script

这篇关于为非交互式Shell正确获取.bashrc的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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