0

I have a tcl script which is a modulefile within the IBM Load Sharing Facitily (lsf) used to configure some environment variables and launch a python script by using the exec command.

When the module is unloaded normally the opposite of all the commands are run, but also the exec command is run as normal. I would like it so that the exec part is only run on module load and not on module unload.

Here is what I tried so far

if { !(is-loaded mymodule)} {
    exec .venv/bin/python mypython.py
}

I also tried this

if { module-info command load } {
    exec .venv/bin/python mypython.py
}

For each one I get a similar error

Module ERROR: invalid bareword "module"
in expression " module-info command [load] ";
should be "$module" or "{module}" or "module(...)" or ...

both exceptions complain either about an invalid bareword (either "is" or "module") depending on which snippet I try. Is my snytax invalid?

Aesir
  • 2,033
  • 1
  • 28
  • 39
  • What have you tried so far? Show us some code… – Donal Fellows Oct 29 '21 at 12:59
  • I added some sample code above. I am not too familiarwith tcl or lsf, so was hoping there was just some easy check that I am not aware of, rather than a hand-crafted solution if that makes sense. – Aesir Oct 29 '21 at 13:07

1 Answers1

0

My syntax was incorrect, in the end I was able to solve the problem with the following:

set is_load_command [module-info command load]

if { $is_load_command == 1 } {
    exec .venv/bin/python mypython.py
}

I had two problems, correctly understanding comparisons in tcl and using return values from a called function. Neither really behaved how I am used to.

Aesir
  • 2,033
  • 1
  • 28
  • 39