annotate bin/procenv.sh @ 567:67e5137b1476

remove blind commit message
author Jeff Hammel <k0scist@gmail.com>
date Mon, 30 Dec 2013 23:05:30 -0800
parents 481b55fc4b96
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
342
481b55fc4b96 added utility to get process env variables
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
1 #!/bin/bash
481b55fc4b96 added utility to get process env variables
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
2
481b55fc4b96 added utility to get process env variables
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
3 # process environment
481b55fc4b96 added utility to get process env variables
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
4 # list process environment variables
481b55fc4b96 added utility to get process env variables
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
5
481b55fc4b96 added utility to get process env variables
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
6 # must be run as root
481b55fc4b96 added utility to get process env variables
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
7 if [[ "$(whoami)" != "root" ]]
481b55fc4b96 added utility to get process env variables
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
8 then
481b55fc4b96 added utility to get process env variables
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
9 echo "must be run as root"
481b55fc4b96 added utility to get process env variables
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
10 exit 1
481b55fc4b96 added utility to get process env variables
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
11 fi
481b55fc4b96 added utility to get process env variables
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
12
481b55fc4b96 added utility to get process env variables
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
13 # loop over arguments
481b55fc4b96 added utility to get process env variables
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
14 for PROG in $@
481b55fc4b96 added utility to get process env variables
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
15 do
481b55fc4b96 added utility to get process env variables
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
16 EXIT=0
481b55fc4b96 added utility to get process env variables
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
17 if PID=$(pidof -x ${PROG})
481b55fc4b96 added utility to get process env variables
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
18 then
481b55fc4b96 added utility to get process env variables
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
19 echo '='${PROG}: ${PID}'='
481b55fc4b96 added utility to get process env variables
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
20 cat /proc/${PID}/environ | tr '\000' '\012' | sort
481b55fc4b96 added utility to get process env variables
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
21 else
481b55fc4b96 added utility to get process env variables
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
22 EXIT=1
481b55fc4b96 added utility to get process env variables
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
23 echo ""
481b55fc4b96 added utility to get process env variables
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
24 fi
481b55fc4b96 added utility to get process env variables
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
25 done