diff --git a/modules/schedulers/condor/condor.scheduler b/modules/schedulers/condor/condor.scheduler
index e2e7ea67e24db5582884361f5344c69f2be1f4e5..b9befe1854c5fd7daf1a38d49e08eb9d66f853d2 100755
--- a/modules/schedulers/condor/condor.scheduler
+++ b/modules/schedulers/condor/condor.scheduler
@@ -56,16 +56,13 @@ scheduler_get_machinefile () {
     export MPI_START_HOST_SLOTS_FILE=$MPI_START_TEMP_FILE
     sort -n < $CONDOR_CONTACT_FILE | awk '{print $2}' > $MPI_START_MACHINEFILE
     # assume CONDOR allocation of machines is "sane"
-    cat $MPI_START_MACHINEFILE | sort | uniq -c | tr -s " " |
+    awk '!x[$0]++' $MPI_START_MACHINEFILE | tr -s " " |
          # this is a subshell, variables changes here are not changed outside!
-         while read line; do
-             slots=`echo $line | cut -f1 -d" "`
-             host=`echo $line | cut -f2 -d" "`
+         while read host; do
+             slots=`grep -c "$host" $MPI_START_MACHINEFILE`
              echo $host >> $MPI_START_HOSTFILE
              echo $host $slots >> $MPI_START_HOST_SLOTS_FILE
          done
-         # this only works in bash
-         # < <( cat $MPI_START_MACHINEFILE | sort | uniq -c | tr -s " " )
     export MPI_START_NHOSTS=`cat $MPI_START_HOSTFILE | wc -l`
     export MPI_START_NSLOTS_PER_HOST=`cat $MPI_START_HOST_SLOTS_FILE | cut -f2 -d" " | sort -n | head -1`
     export MPI_START_NSLOTS=`cat $MPI_START_MACHINEFILE | wc -l`
diff --git a/modules/schedulers/lsf/lsf.scheduler b/modules/schedulers/lsf/lsf.scheduler
index 2d7321c49cedb2a914d262f7383fcf00cdd06c3f..2d1107ce11ab43239243e8bf7fe2f49fb340de0d 100755
--- a/modules/schedulers/lsf/lsf.scheduler
+++ b/modules/schedulers/lsf/lsf.scheduler
@@ -43,16 +43,14 @@ build_lsb_hosts () {
     for host in $LSB_HOSTS; do
         echo $host >> $MPI_START_MACHINEFILE
     done
-    cat $MPI_START_MACHINEFILE | sort | uniq -c | tr -s " " |
+    awk '!x[$0]++' $MPI_START_MACHINEFILE | tr -s " " |
         # this is a subshell, variables changes here are not changed outside!
-        while read line; do
-            slots=`echo $line | cut -f1 -d" "`
-            host=`echo $line | cut -f2 -d" "`
+        while read host; do
+            slots=`grep -c "$host" $MPI_START_MACHINEFILE`
             echo $host >> $MPI_START_HOSTFILE
             echo $host $slots >> $MPI_START_HOST_SLOTS_FILE
         done
     export MPI_START_NHOSTS=`cat $MPI_START_HOSTFILE | wc -l`
-    export MPI_START_NSLOTS_PER_HOST=`cat $MPI_START_HOST_SLOTS_FILE | cut -f2 -d" " | sort -n | head -1`
     export MPI_START_NSLOTS=`cat $MPI_START_MACHINEFILE | wc -l`
     return 0
 }
@@ -88,7 +86,6 @@ build_lsb_mcpu_hosts () {
     done
     export MPI_START_NHOSTS=$total_hosts
     export MPI_START_NSLOTS=$total_slots
-    export MPI_START_NSLOTS_PER_HOST=`cat $MPI_START_HOST_SLOTS_FILE | cut -f2 -d" " | sort -n | head -1`
     return 0
 }
 
@@ -104,5 +101,8 @@ scheduler_get_machinefile () {
     else
         build_lsb_mcpu_hosts
     fi
+    st=$?
+    export MPI_START_NSLOTS_PER_HOST=`cat $MPI_START_HOST_SLOTS_FILE | cut -f2 -d" " | sort -n | head -1`
+    return $st
 }
 
diff --git a/modules/schedulers/pbs/pbs.scheduler b/modules/schedulers/pbs/pbs.scheduler
index 8e638421d07c5a493198e5ee34a3fd13c172ba7b..ad61269c3c22aa9d5d6af17799d188f423895bf5 100755
--- a/modules/schedulers/pbs/pbs.scheduler
+++ b/modules/schedulers/pbs/pbs.scheduler
@@ -36,16 +36,13 @@ scheduler_get_machinefile () {
     mpi_start_mktemp
     export MPI_START_HOST_SLOTS_FILE=$MPI_START_TEMP_FILE
     cat $PBS_NODEFILE > $MPI_START_MACHINEFILE
-    cat $MPI_START_MACHINEFILE | sort | uniq -c | tr -s " " |
+    awk '!x[$0]++' $MPI_START_MACHINEFILE | tr -s " " |
          # this is a subshell, variables changes here are not changed outside!
-         while read line; do
-             slots=`echo $line | cut -f1 -d" "`
-             host=`echo $line | cut -f2 -d" "`
+         while read host; do
+             slots=`grep -c "$host" $MPI_START_MACHINEFILE`
              echo $host >> $MPI_START_HOSTFILE
              echo $host $slots >> $MPI_START_HOST_SLOTS_FILE
          done
-         # this only works in bash
-         # < <( cat $MPI_START_MACHINEFILE | sort | uniq -c | tr -s " " )
     export MPI_START_NHOSTS=`cat $MPI_START_HOSTFILE | wc -l`
     export MPI_START_NSLOTS_PER_HOST=`cat $MPI_START_HOST_SLOTS_FILE | cut -f2 -d" " | sort -n | head -1`
     export MPI_START_NSLOTS=`cat $MPI_START_MACHINEFILE | wc -l`
diff --git a/modules/schedulers/slurm/slurm.scheduler b/modules/schedulers/slurm/slurm.scheduler
index 6dce747ea17f1ce735017a0f5b7ef5ee6658ba4e..593d77d12f19ef3265297ccdf887224a27e2b92b 100755
--- a/modules/schedulers/slurm/slurm.scheduler
+++ b/modules/schedulers/slurm/slurm.scheduler
@@ -51,11 +51,10 @@ scheduler_get_machinefile () {
             return 13
         fi
     fi
-    cat $MPI_START_MACHINEFILE | sort | uniq -c | tr -s " " |
+    awk '!x[$0]++' $MPI_START_MACHINEFILE | tr -s " " |
          # this is a subshell, variables changes here are not changed outside!
-         while read line; do
-             slots=`echo $line | cut -f1 -d" "`
-             host=`echo $line | cut -f2 -d" "`
+         while read host; do
+             slots=`grep -c "$host" $MPI_START_MACHINEFILE`
              echo $host >> $MPI_START_HOSTFILE
              echo $host $slots >> $MPI_START_HOST_SLOTS_FILE
          done