Upgraded the ParaView build scripts to version 3.3-cvs.
[OpenFOAM-1.5.x.git] / bin / foamProcessInfo
blob6bd5e89ba155a3ef223e147f2041881d1a7ac83a
1 #!/bin/sh
2 #------------------------------------------------------------------------------
3 # ========= |
4 # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 # \\ / O peration |
6 # \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
7 # \\/ M anipulation |
8 #-------------------------------------------------------------------------------
9 # License
10 # This file is part of OpenFOAM.
12 # OpenFOAM is free software; you can redistribute it and/or modify it
13 # under the terms of the GNU General Public License as published by the
14 # Free Software Foundation; either version 2 of the License, or (at your
15 # option) any later version.
17 # OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
18 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 # for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with OpenFOAM; if not, write to the Free Software Foundation,
24 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 # Script
27 # foamProcessInfo
29 # Description
30 # Collects user's process status information into file. File contains one
31 # line per process:
33 # pid state command
35 # state is one of 'RUNN' 'SUSP' 'OTHR',
36 # command is the argv[0]
38 # Tested on Linux,IRIX,SunOS
40 #-------------------------------------------------------------------------------
42 PROGNAME=`basename $0`
43 TMPFILE=/tmp/${PROGNAME}$$.tmp
44 AWKFILE=/tmp/${PROGNAME}$$.awk
46 if [ `uname -s` = 'Linux' ]; then
47 ECHO='echo -e'
48 else
49 ECHO='echo'
53 if [ $# -ne 1 ]; then
54 echo "Error : $PROGNAME : insufficient arguments" 1>&2
55 exit 1
59 outputFile=$1
60 rm -f $outputFile
63 ARCH=`uname`
65 #-- Force standards behaving ps
66 # Get info on all $USER processes
67 case $ARCH in
68 HP-UX*)
69 UNIX95=a; export UNIX95
71 IRIX*)
72 _XPG=1; export _XPG
74 esac
76 case $ARCH in
77 SunOS*)
78 ps -e -o 'pid,f,s,comm' > $TMPFILE
80 HP-UX*)
81 ps -e -o 'pid,flags,state,comm' > $TMPFILE
84 ps -e -o 'pid,flag,state,comm' > $TMPFILE
85 esac
88 rm -f $AWKFILE; touch $AWKFILE
89 case $ARCH in
90 IRIX*)
91 echo '($2 == 40) || ($3 == "T") {print $1 " SUSP // " $4; next}' >> $AWKFILE
92 echo '($3 == "R") || ($3 == "S") || ($3 == "D") {print $1 " RUNN // " $4; next}' >> $AWKFILE
93 echo '{print $1 " OTHR // " $4}' >> $AWKFILE
95 Linux*)
96 echo '($3 == "T") {print $1 " SUSP // " $4; next}' >> $AWKFILE
97 echo '($3 == "R") || ($3 == "S") || ($3 == "D") {print $1 " RUNN // " $4; next}' >> $AWKFILE
98 echo '{print $1 " OTHR // " $4}' >> $AWKFILE
100 SunOS*)
101 echo '($3 == "T") {print $1 " SUSP // " $4; next}' >> $AWKFILE
102 echo '($3 == "O") || ($3 == "S") || ($3 == "R") {print $1 " RUNN // " $4; next}' >> $AWKFILE
103 echo '{print $1 " OTHR // " $4}' >> $AWKFILE
106 echo "Error : $PROGNAME : unsupported achitecture $ARCH"
108 esac
110 $ECHO "(" > $outputFile
111 tail +2 $TMPFILE | awk -f $AWKFILE >> $outputFile
112 $ECHO ")" >> $outputFile
114 rm -f $TMPFILE $AWKFILE
116 #------------------------------------------------------------------------------