如何获取环境模块模块文件以在加载模块时打印消息?

How to get an Environment Module modulefile to print a message upon loading the module?

我刚刚了解了如何制作 modulefiles 以在我的集群上加载软件的基础知识。其他环境模块(由管理员创建)在加载时打印一条消息: $ module load Name Welcome to Name/version.1.2.3 如何将其添加到模块文件?我喜欢快速确认我确实加载了我想要的模块。我尝试了 man page 中的一些东西(例如 module-info name),但没有成功(或者我做错了)。

谢谢

您可以将 puts stderr 语句添加到模块文件,以将消息打印到终端。

puts stderr "** INFO: 'Welcome, Module loaded'"

如果您 "only" 希望消息在 运行 module load 时打印(而不是在 运行 module unload 或其他命令时),那么您可以使用这样的语句:

if [ module-info mode load ] {
    puts stderr "your text here"
}

参考:https://sourceforge.net/p/modules/mailman/message/34597600/