Perl Script to install MPI Libraries on Raspberry Pi

This particular script runs through the first 16 Pi’s in our super-computer cluster and installs three dependent MPI Libraries: libcr-dev, mpich2, and mpich2-doc.

#!/usr/bin/perl
 
#Creates a loop to do all the pi's in the cluster
for ($count = 2; $count <= 17; $count++) {
 
  my $host = "192.168.0.$count";
  #Installs the libcr-dev library
  system("ssh pi@$host 'sudo apt-get --yes --force-yes install libcr-dev'");
    if ( $? == -1 )
    {
      print "command failed: $!n";
    }
    else
    {
      print "command exited with value %d", $? >> 8;
    }

  #Installs the mpich2 library
  system("ssh pi@$host 'sudo apt-get --yes --force-yes install mpich2'");
    if ( $? == -1 )
    {
      print "command failed: $!n";
    }
    else
    {
      print "command exited with value %d", $? >> 8;
    }
    
  #Installs the mpich2-doc library
  system("ssh pi@$host 'sudo apt-get --yes --force-yes install mpich2-doc'");
    if ( $? == -1 )
    {
      print "command failed: $!n";
    }
    else
    {
      print "command exited with value %d", $? >> 8;
    }
}

You may also like

Leave a Reply

Your email address will not be published. Required fields are marked *