#!/bin/sh

#
# File: pvmslave
# Auth: Christian Hansen (chansen@cs.umd.edu)
#       University of Maryland, College Park
# Desc: Slave pvmd script for IBM PE jobs
# Date: 07/09/04
#

# see if we are the master process
thishost=`hostname`
if test "$1" = "$thishost"; then
  echo "Master pvmd running on $thishost"
  exit
fi

# wait for the slave command to appear in the master's output
slavecmd=""
while test "$slavecmd" = ""; do
  sleep 1
  slavecmd=`grep "lib/pvmd.*$thishost" master.out`
done

# run the slave pvmd command and let the master know
eval "$slavecmd >> master.in"
echo "Slave pvmd running on $thishost"
