#!/depot/local/bin/perl5.8.0
my @data = `module avail icwbev_plus `;
print "Data Array : @data \n " ;
my $data1 = `module avail icwbev_plus `;
print "Data $data1 \n" ;
my $data2 = system (" module avail icwbev_plus ");
print "S Data $data2 "
Output :
Data Array :
Data
S Data -1
I am not getting why it is not storing output to a variable. Please help me to solve this. Thanks in advance.
The
modulecommand is a shell alias or a function. Thus it cannot be called directly via a `` or asystemcall.To get the output of an avail sub-command, you should call the
modulecmdcommand which is called by themoduleshell alias/function.To get the location of
modulecmdon your system, type in a regular shell sessiontype modulewhich exposes the command called by themoduleshell alias/function.The fully qualified path to the
modulecmdcommand can then be used through a back-tick or asystemcall to get the result of anavailsub-command:To get the output of a
module availcommand (in terse format to simplify parsing):Note the
--terseformat used to simplify result parsing. Also stderr is redirected to stdout to catch the actual output of the command (asmodulecmdprimarily uses stdout to output environment change commands).