catamount
catamount

Reputation:

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

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?

Upvotes: 2

Views: 16353

Answers (3)

zega
zega

Reputation: 159

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.

Upvotes: 4

idupree
idupree

Reputation: 770

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.)

Upvotes: -1

eduffy
eduffy

Reputation: 40252

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.

Upvotes: 1

Related Questions