user1876128
user1876128

Reputation: 91

How to execute "load module X" in Perl

I'm having problems loading a kernel module from Perl.

I have already tried:

system ("module load X");

system ´module load X´ 

exec(module load X);

It complains

Can't exec "module": No such file or directory

Upvotes: 0

Views: 1673

Answers (2)

ikegami
ikegami

Reputation: 386551

The proper function is indeed system.

use IPC::System::Simple qw( system );
system("module load X");

(By using IPC::System::Simple's version, we don't have to do any error checking.)

If the kernel can't find module, it's because it's not in the PATH. You can either adjust the PATH or use the full path to the executable.

system("/path/to/module load X");

Of course, I'm assuming your command actually makes sense since I don't know anything about loading kernel modules. That might not be a fair assumption since you said load module in one place and module load in another. Double check the command.

Upvotes: 1

René Nyffenegger
René Nyffenegger

Reputation: 40593

You probably want

use X;

But I guess that you should read some introductionary material on Perl if you're struggling why system or exec doesn't load a module.

Upvotes: 1

Related Questions