简体   繁体   中英

Prevent exec command running on module unload ibm load sharing facilty

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM