digimaus

postfg.sh

Mar 8th, 2022 (edited)
682
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.54 KB | None | 0 0
  1. #!/bin/bash
  2. #####################################################################
  3. ## FIDOGAZETTE Posting Script
  4. ## By Sean Dennis
  5. ##
  6. ## Updated on 8 March 2022 at 2320 EST
  7. ##
  8. ## This script reads the DOS-formatted text newsletter file, strips
  9. ## the formfeed from the top of each page, splits the file into
  10. ## individual text files delineated by the page header, then
  11. ## posts each text file in order into the FIDOGAZETTE echo using
  12. ## mbmsg.
  13. ##
  14. #####################################################################
  15. export MBSE_HOME=/opt/mbse
  16. cd $MBSE_HOME/work
  17. FILENAME="fgaz$1$2.nws"
  18. # Prevent PEBCAK error
  19. if [ ! -f  $FILENAME ]; then
  20.   printf "\n\n"
  21.   echo "You need to copy the newsletter into the directory!"
  22.   printf "\n\n"
  23.   exit 1
  24. fi
  25. # Remove the formfeed control code from each page header
  26. # FF = ^L = 0C (hex)
  27. # -i = do the changes inline putting file into memory to edit
  28. sed -i 's/\x0c//' $FILENAME
  29. # Split file into pages delineated at the top with "FGAZ"
  30. # Pages start at xx00 (actual filename)
  31. csplit -s $FILENAME '/FGAZ/' '{*}'
  32. rm "fgaz$1$2.nws"
  33. I=0
  34. # Start posting all of the pages
  35. for file in `ls` ; do
  36.   # If digit is < 10, pad with leading zero for csplit's output
  37.   printf -v J "%02d" $I
  38.   # If it's the title page, use subject w/o page #
  39.   if [ $I -eq 0 ]; then
  40.     SUBJECT="FidoGazette V$1 I$2"
  41.   else
  42.     SUBJECT="FidoGazette V$1 I$2 Page $I"
  43.   fi
  44.   # Call mbmsg to post text file into FIDOGAZETTE echo
  45.   $MBSE_ROOT/bin/mbmsg post "All" 113 "$SUBJECT" $MBSE_HOME/work/xx$J - -q
  46.   ((I++))
  47. done
  48. rm xx*
  49.  
Add Comment
Please, Sign In to add comment