views:

787

answers:

1

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?

A: 

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.

eduffy
Thanks for the quick response, but something like the below isn't working:adm@mach:~> cat test1.sh#!/bin/bashsource /etc/profileshopt -s expand_aliasesmodule load MySQL#do stuff with mysqladm@mach:~> ./test1.sh./test1.sh: line 6: module: command not found
<code>adm@mach:~> cat test1.sh#!/bin/bashsource /etc/profileshopt -s expand_aliasesmodule load MySQL#do stuff with mysqladm@mach:~> ./test1.sh./test1.sh: line 6: module: command not found</code>
What about changing your first line to "/bin/bash -l"?
eduffy
That worked. Thank you.