0

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
ikegami
  • 367,544
  • 15
  • 269
  • 518
user1876128
  • 91
  • 14
  • See this similar question: http://stackoverflow.com/questions/1127383/how-to-issue-module-load-in-a-shell-or-perl-script-i-e-non-interactively –  Feb 25 '13 at 11:03
  • I have already checked this , the answers are given regrading bash scripting not Perl – user1876128 Feb 25 '13 at 11:13
  • uh, none of the snippets you gave give the output you said you got! Or any output at all, since you didn't do any error checking. Please fix up your answer. – ikegami Feb 25 '13 at 11:30

2 Answers2

1

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.

René Nyffenegger
  • 39,402
  • 33
  • 158
  • 293
1

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.

ikegami
  • 367,544
  • 15
  • 269
  • 518