How to issue “module load” in a shell or Perl script (i.e., non-interactively)

梦想的初衷 提交于 2019-12-23 03:35:07

问题


I can use the "module load xyz" command interactively, but when run from a script, it says it can't find the "module" command. Is there any way of loading modules in a script?


回答1:


Start your bash script like this:

#!/bin/bash -l

Note that modules loaded after this with module load xyz will only be available from inside the script file.




回答2:


Try

source /etc/profile

If that doesn't work, you most likely have a problem with aliases. You may need

shopt -s expand_aliases

in your script.




回答3:


If by modules you mean Linux kernel modules, look into modprobe (or the more low-level insmod). There's usually no need to use whatever aliases (like module) that your Linux distro loaded into your shell.

(For example, I don't even have a module command on my distro/setup, so I can't try it to see what kind of modules you're referring to.)



来源:https://stackoverflow.com/questions/1127383/how-to-issue-module-load-in-a-shell-or-perl-script-i-e-non-interactively

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!