SyP-

monitorify

Jun 24th, 2021
56
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2.  
  3.    
  4. monitorify () {
  5.  
  6. MSG=""
  7. if [ ! -z "$NCOMMAND" ];then
  8.     if [ -z "${commands[0]}" ]; then
  9.         commands[0]=$1
  10.     elif [ -z "${commands[1]}" ]; then
  11.         commands[1]=$1
  12.     elif [ -z "${commands[2]}" ]; then
  13.         commands[2]=$1
  14.     else
  15.         MSG="all slots are occupied"
  16.     fi
  17. fi
  18. unset NCOMMAND
  19. echo "status: $MSG"
  20. echo ""
  21. i=0
  22. while [ $i -le 2 ]; do
  23. if [ ! -z "${commands[$i]}" ]; then
  24.     echo -e "\e[32mCommand ${commands[$i]}\e[0m"
  25.     echo ""
  26.     sh -c "${commands[$i]}  2> /dev/null"
  27.     echo ""
  28.    
  29.     ((i++))
  30. else
  31.     break
  32. fi
  33.    
  34.  
  35. done
  36. }
  37.  
  38.  
  39.  
  40.  
  41.  
  42. while true;do
  43. clear
  44.     monitorify "$NCOMMAND"
  45.  
  46.  
  47.     echo "(r)efresh new (c)ommand (q)uit: "
  48.     read -rsn1 ACTION
  49.  
  50.     case $ACTION in
  51.  
  52.         r|R)    echo "Refresh..."
  53.             ;;
  54.         c|C)    read -p "New command to monitorify: " NCOMMAND
  55.             ;;
  56.         q|Q)    echo "Exit..."
  57.             exit 0
  58.     esac
  59.  
  60. done
RAW Paste Data