###################
#INPUT: -l nodelist
#Creates a directory on planet lab machines
###################

NODEFILE=""
while [ $# -ge 1 ]; 
do
   case $1 in

     -l)   shift ; NODEFILE="$1";;
   esac

   shift
done 

PLANETRSA=planet_rsa
TARGETDIR="~/p2p_gaurav"

if [ ! -f $NODEFILE ];then
  echo "File does not exist."
  exit 1
elif [ ! -r $NODEFILE ]; then
     echo "File cannot be read"
     exit 1
fi

#read file
exec 3<&0
exec 0<$NODEFILE

echo "" > failedsites
while read line
do
   echo $line
   ssh -i $PLANETRSA columbia_salman@${line} "mkdir -p ${TARGETDIR}"  < /dev/null
   if [ $? != 0 ];then
      echo $line >> failedsites 
   fi
   echo "";
done

