Thiesi

mysticpage

Jan 5th, 2019
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.97 KB | None | 0 0
  1. #!/usr/pkg/bin/bash
  2. #
  3. # mysticpage - (c) by Thiesi, 2019
  4.  
  5. ### Adjust the following variables to suit your need.
  6. ### Numbers smaller than 5 for DelayBetweenPagingMessages might not emit another beep.
  7. ### OnScreenMessageWaitingTime determines how long the script pauses before
  8. ### moving on after displaying a message to the BBS user.
  9.  
  10. NumberOfPagingMessages=6
  11. DelayBetweenPagingMessages=5
  12. OnScreenMessageWaitingTime=3
  13.  
  14. if [[ $# -eq 2 ]]; then
  15.         SysOpName=$1
  16.         PagingUser=$2
  17. else
  18.         echo "SYNTAX: mysticpage <SysOp name> <name of paging user>"
  19.         sleep $OnScreenMessageWaitingTime
  20.         exit
  21. fi
  22.  
  23. echo -ne "Please enter a reason for paging: "
  24. read -e ReasonForPaging
  25. if [ -z  "$ReasonForPaging" ]; then
  26.         ReasonForPaging="*** no reason given ***"
  27. fi
  28.  
  29. PageSysOp()
  30. {
  31.         echo -e "Incoming chat request from BBS user $PagingUser.\nThey stated the following reason for paging: $ReasonForPaging" | write $SysOpName $tty 2> /dev/null
  32. }
  33. tty=(`w -hi $SysOpName | awk '{ print $2 }' | grep -v TTY`)
  34.  
  35. if [ $? != 0 ]; then
  36.         echo "Sorry, but the SysOp is currently unavailable. Please try again later."
  37.         sleep $OnScreenMessageWaitingTime
  38.         exit
  39. else
  40.         echo -ne "Paging SysOp for approximately `expr $NumberOfPagingMessages '*' $DelayBetweenPagingMessages` seconds now..."
  41.         for ((i=0;i<$NumberOfPagingMessages;i++))
  42.         do
  43.                 echo -ne "."
  44.                 PageSysOp
  45.                 if [ $? != 0 ]; then
  46.                         echo -e "\nSorry, but the SysOp is busy at the moment. Please try again later."
  47.                         sleep $OnScreenMessageWaitingTime
  48.                         exit
  49.                 fi
  50.                 echo -ne "."
  51.                 sleep $DelayBetweenPagingMessages
  52.         done
  53.         echo "...done."
  54.         echo "The SysOp has been notified and might engage chat."
  55.         echo "You may continue using the BBS normally."
  56.         sleep $OnScreenMessageWaitingTime
  57. fi
Advertisement
Add Comment
Please, Sign In to add comment