h8rt3rmin8r

ngrok-pids.sh

Oct 20th, 2020
847
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #! /usr/bin/env bash
  2. #>
  3. #> [ ngrok-pids ]
  4. #>
  5. #>    List all active ngrok process IDs
  6. #>
  7. #>    No inputs are required when invoking this script.
  8. #>
  9.  
  10. function help_text() {
  11.     cat "$0" \
  12.         | grep -E '^#[>]' \
  13.         | sed 's/^..//'
  14.  
  15.     return $?
  16. }
  17.  
  18. if [[ "${1}" =~ ^[-][hH]$ || "${1}" =~ ^[-]help$ ]]; then
  19.     help_text
  20.  
  21.     exit $?
  22. fi
  23.  
  24. ps -aux \
  25.     | tr -s '\t' ' ' \
  26.     | tr -s ' ' ' ' \
  27.     | sed '/grep/d' \
  28.     | sed "/ngrok-pids/d" \
  29.     | grep -E 'ngrok' \
  30.     | cut -d ' ' -f2
  31.  
  32. exit $?
  33.  
RAW Paste Data