#!/bin/csh -f

# run with command 'pexec "csh ps.sh"'
# this will return a fill which lists all "interesting" 
# processes on all nodes

# set up names for things - makes it neater.
set hname  = ${HOSTNAME}
set uname  = ${USER}
set fname  = $uname.ps.txt
set writef = /data/$uname/$fname
set copyf  = /home/$uname/$fname


# create file
touch $writef

# just some nice formatting
echo "================" >> $writef

# which node are we on?
echo $hname >> $writef

# more formatting
echo "----------------" >> $writef

# find out what you're running on this node
ps -U $uname | grep -v rsh | grep -v csh | grep -v zsh | grep -v bash | grep -v perl | grep -v grep | grep -v ps >> $writef

# more formatting
echo "----------------" >> $writef

# create file to copy back to
touch $copyf
# copy results back
cat $writef >> $copyf

# remoce file on host node
rm -f $writef