walterdejong / pconsole

admin tool for typing into multiple terminal windows at once
https://walterdejong.github.io/pconsole/
22 stars 5 forks source link

it's ps -j on BSDish systems #1

Open walterdejong opened 14 years ago

walterdejong commented 14 years ago

On BSD-ish systems, the ps command likes the -j argument rather than the -ef arguments used in pconsole.sh.

As pointed out a long time ago by both Marek Jaros and Davin Reade.

walterdejong commented 14 years ago
--- pconsole.sh.orig    Wed Dec 29 10:37:44 2004
+++ pconsole.sh Wed Dec 29 11:24:29 2004
@@ -72,8 +72,13 @@
        set -x
    fi

-   PS_PERSONALITY=posix        # may be needed for GNU ps :P
-   ps -ef 2>/dev/null | awk '{ print $3 " " $6 }' | egrep "^$1" | awk '{ print $2 }'
+   os=`uname`
+   if [ "$os" = "OpenBSD" -o "$os" = "FreeBSD" ]; then
+       ps -j 2>/dev/null | awk '{ print $3 " tty" $8 }' | egrep "^$1" | awk '{ print $2 }'
+   else
+       PS_PERSONALITY=posix        # may be needed for GNU ps :P
+       ps -ef 2>/dev/null | awk '{ print $3 " " $6 }' | egrep "^$1" | awk '{ print $2 }'
+   fi
 }
walterdejong commented 14 years ago

I'm not fond of checking OSes with uname, because NetBSD, DragonFlyBSD, MacOS X and others also use BSD ps. Maybe we can use "ps -ej", which works on Linux as well as BSD, only the output format is very different (?)