summaryrefslogtreecommitdiff
path: root/scripts/pid2ps
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/pid2ps')
-rwxr-xr-xscripts/pid2ps22
1 files changed, 22 insertions, 0 deletions
diff --git a/scripts/pid2ps b/scripts/pid2ps
new file mode 100755
index 0000000..25cb6e5
--- /dev/null
+++ b/scripts/pid2ps
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+# Simple PID to PS resolver
+
+pid=$1
+if [[ -z $pid ]]; then
+ echo "[*] Usage: pid2ps <PID>"
+ exit 1
+fi
+
+if [[ $pid =~ ^[0-9]+$ ]]; then
+ if name=$(/bin/cat /proc/$pid/comm 2>/dev/null); then
+ echo $name
+ else
+ echo "[!] No such process"
+ exit 1
+ fi
+else
+ echo "[!] Invalid PID"
+ exit 1
+fi
+