Thx for the suggestion.
Before asking I tried briefly but without success.
I was not even able to run a simple
mkdir -p /some/path
That’s why I asked here.
Of course I will try again following your suggestions!
Roberto
Sent with Spark
On 27 May 2025 at 19:04 +0200, Paul Markfort <pau...@gm...>, wrote:
> module scripts are also tclsh scripts.
>
> You would probably use the tcl exec command:
> https://www.tcl-lang.org/man/tcl/TclCmd/exec.html#M3
>
> Make sure that you redirect stdout, as stdout will be evaluated by the shell calling modules (which could result in strange behavior from your module script).
>
> You would put this in an
> if {[module-info mode load]} {
> block (so it is only invoked on load)
>
> NOTE: there may be other module states you may want to run it under as well (see: man modulefile, for more info on "module-info mode").
>
>
>
> On 2025-05-27 11:39 AM, InfnPi wrote:
> > Hi,
> > I have a (probably) stupid question.
> >
> > I would linke to set-up an user environment for a certain project for users and then configure it accordingly.
> >
> > The setup phase is usually done once and involves running a script which makes some changes to the filesystem.
> > Typically i will create some "standard" directory structures and link some files/directories to this structure.
> >
> > Once the setup is complete, i need to configure the environment for using it.
> >
> > This second part is easily dome with modules but i was wondering if there is any way to execute a script (that does not have environment settings) to check if a particular directory structure is in place.
> > If it is not there it will create it, otherwise it will just skip it and proceed to the configuration part.
> >
> > Of course this first part would have just to be executed on a module load command and should not be reverted by a module unload or switch command.
> >
> > Something like:
> > exec-shell-script bash ./path/to/script/Create.sh
> > (instead of bash it could be anything like another shell, a python script or even a program written by the user)
> >
> > followed by some standard modulefile commands that set user environment variables.
> >
> > A user would then alway call a single modulefile regardless of the fact that the directory structure is already in place.
> >
> > Something like:
> > module load setup/ProjectXXX
> >
> > If it is the first time it is run it will create the complete directory structure (with directories, links etc) and then setup the environment variables (tools, licenses, paths etc)
> > If the user runs it a second time the script would still be executed but being the directory structure already in place it would just skip that part (this is handled by the script itself) and go to the environment configuration part.
> >
> > Of course, in case of a:
> > module unload setup/ProjectXXX
> > only the environment part would be undone and the whole directory structure would stay as before.
> >
> > Of course this procedure has not to be a one step solution but it could well be one that reguires loading two different modules,
> > the first one that creates/checks the structure and a second one that configures the environment.
> >
> > I tried to look if this is possible but did not find a solution.
> >
> > Many thx in advance,
> > Roberto
> >
> >
> >
> > _______________________________________________
> > Modules-interest mailing list
> > Mod...@li...
> > https://lists.sourceforge.net/lists/listinfo/modules-interest
> >
>
> --
> --------------------------------------------------------
> The views and opinions expressed above are strictly
> those of the author(s). The content of this message has
> not been reviewed nor approved by any entity whatsoever.
> --------------------------------------------------------
> Paul FM Info: http://paulfm.com/~paulfm/
> --------------------------------------------------------
>
>
> _______________________________________________
> Modules-interest mailing list
> Mod...@li...
> https://lists.sourceforge.net/lists/listinfo/modules-interest
|