Last active
May 28, 2020 15:47
-
-
Save isaaclw/3f56e8813888450eb7f072b297170709 to your computer and use it in GitHub Desktop.
Checks a Pid for a variable in the environment #bash #env
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# isaac ALL = NOPASSWD: /home/isaac/.bin/sudo_envcat | |
pid="$1" | |
if [ "$pid" == 't' ] && [ $(whoami) == 'root' ]; then | |
exit 0 | |
fi | |
var="$2" | |
output=$(cat /proc/$pid/environ | tr '\0' '\n' | grep "$var" | cut -d '=' -f2-) | |
if [ -n "$DEBUG" ] && [ -n "$output" ]; then | |
echo "$pid -> $output" | |
else | |
echo "$output" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment