summaryrefslogtreecommitdiff
path: root/scripts/pid2ps
blob: 25cb6e5d5ef42104dcf9f7c3b9ea6bd6d697380f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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