-1

I am trying to call a bash script in perl, by doing this -

my $which_mpi = "/sw/tools/tacc/builds/carter/site/salt_which_mpi";
$mpi_stack = system("$which_mpi",-n);

the problem is that I want the script to execute when it is called by system command in line

$mpi_stack = system("$which_mpi",-n);

but the problem with this is while assigning the path in $which_mpi it automatically executes the script. So instead of me getting this value

WHICH_MPI : /sw/tools/salt/builds/carter/altd/bin/site/salt_which_mpi

I am getting the path with the output of the bash script like

WHICH_MPI : /sw/tools/salt/builds/carter/altd/bin/site/salt_which_mpiopenmpi 1.6.1

where openmpi 1.6.1 is the output of my salt_which_mpi bash script.

kay
  • 176
  • 2
  • 10

1 Answers1

1

You can use perl's backtick operator

`bash -c "$WHICH_MPI"`

take a look at this question: another stackoverflow question

Community
  • 1
  • 1
Marco Aurelio
  • 20,724
  • 1
  • 17
  • 16
  • No worries I used this and it worked $mpi_stack = "`$which_mpi --name`; "thanks! which is close to you suggested. – kay May 22 '14 at 19:38