#!/bin/csh # # Michael L. Love, Tue Aug 15 14:14:26 EDT 2006, GPL # # loop2pipe-1.1 # # To pipe from a foreach loop, use a buffer to fill a list, # then pipe out the result as below. # setenv theBuffer ' ' setenv theList ' ' foreach i (` cat /etc/hosts|grep 'n..$'|head -30 |cut -f3`) # fill the buffer with comma appended setenv theBuffer ' '`qmgr -c "list node "$i | grep -A1 Node`',' # append buffer to list setenv theList `echo $theList``echo $theBuffer` end echo # pipe out the result as desired echo $theList | sed s/','/'\n'/g | grep job-exclusive | sort +2 echo $theList | sed s/','/'\n'/g | grep free | sort +2 echo $theList | sed s/','/'\n'/g | grep offline | sort +2 echo echo -n 'nodes_free = ' echo $theList | sed s/','/'\n'/g | grep free | wc -l echo -n 'nodes_offline = ' echo $theList | sed s/','/'\n'/g | grep offline | wc -l echo -n 'nodes_used = ' echo $theList | sed s/','/'\n'/g | grep job-exclusive | wc -l echo `qmgr -c 'list server' | grep total_jobs`