Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #####################################################################
- ## FIDOGAZETTE Posting Script
- ## By Sean Dennis
- ##
- ## Updated on 8 March 2022 at 2320 EST
- ##
- ## This script reads the DOS-formatted text newsletter file, strips
- ## the formfeed from the top of each page, splits the file into
- ## individual text files delineated by the page header, then
- ## posts each text file in order into the FIDOGAZETTE echo using
- ## mbmsg.
- ##
- #####################################################################
- export MBSE_HOME=/opt/mbse
- cd $MBSE_HOME/work
- FILENAME="fgaz$1$2.nws"
- # Prevent PEBCAK error
- if [ ! -f $FILENAME ]; then
- printf "\n\n"
- echo "You need to copy the newsletter into the directory!"
- printf "\n\n"
- exit 1
- fi
- # Remove the formfeed control code from each page header
- # FF = ^L = 0C (hex)
- # -i = do the changes inline putting file into memory to edit
- sed -i 's/\x0c//' $FILENAME
- # Split file into pages delineated at the top with "FGAZ"
- # Pages start at xx00 (actual filename)
- csplit -s $FILENAME '/FGAZ/' '{*}'
- rm "fgaz$1$2.nws"
- I=0
- # Start posting all of the pages
- for file in `ls` ; do
- # If digit is < 10, pad with leading zero for csplit's output
- printf -v J "%02d" $I
- # If it's the title page, use subject w/o page #
- if [ $I -eq 0 ]; then
- SUBJECT="FidoGazette V$1 I$2"
- else
- SUBJECT="FidoGazette V$1 I$2 Page $I"
- fi
- # Call mbmsg to post text file into FIDOGAZETTE echo
- $MBSE_ROOT/bin/mbmsg post "All" 113 "$SUBJECT" $MBSE_HOME/work/xx$J - -q
- ((I++))
- done
- rm xx*
Add Comment
Please, Sign In to add comment