From 09b34f9cbde4a28a60fef8e2dad6cc4346cbcb06 Mon Sep 17 00:00:00 2001 From: Chris Koeritz Date: Wed, 24 Jun 2015 16:27:44 -0400 Subject: [PATCH] added ability to pass -u USERNAME to psfind. --- scripts/core/functions.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/scripts/core/functions.sh b/scripts/core/functions.sh index eee56fe3..69a5a78f 100644 --- a/scripts/core/functions.sh +++ b/scripts/core/functions.sh @@ -110,9 +110,19 @@ if [ -z "$skip_all" ]; then #echo ==== #echo patterns list is: "${patterns[@]}" #echo ==== + + local user_flag + if [ "${patterns[0]}" == "-u" ]; then + user_flag="-u ${patterns[1]}" +echo "found a -u parm and user=${patterns[1]}" + # void the two elements with that user flag so we don't use them as patterns. + unset patterns[0] patterns[1]= + fi + local PID_DUMP="$(mktemp "$TMP/zz_pidlist.XXXXXX")" local -a PIDS_SOUGHT if [ "$OS" == "Windows_NT" ]; then +#hmmm: windows isn't implementing the user flag yet! # windows case has some odd gyrations to get the user list. if [ ! -d c:/tmp ]; then mkdir c:/tmp @@ -140,7 +150,7 @@ if [ -z "$skip_all" ]; then | sed -n -e "$appropriate_pattern")) done else - /bin/ps $extra_flags wuax >$PID_DUMP + /bin/ps $user_flag wuax >$PID_DUMP #echo ==== #echo got all this stuff in the pid dump file: #cat $PID_DUMP @@ -205,10 +215,9 @@ if [ -z "$skip_all" ]; then extra_flags= if [ "$OS" = "Windows_NT" ]; then # special case for windows. - extra_flags=-W ps | head -1 for curr in $p; do - ps $extra_flags | grep "$curr" + ps -W | grep "$curr" done else # normal OSes can handle a nice simple query. -- 2.34.1