OpenBCM V1.08-5-g2f4a (Linux)

Packet Radio Mailbox

IZ3LSV

[San Dona' di P. JN]

 Login: GUEST





  
K3CHB  > LINUX    01.08.21 10:08l 114 Lines 4246 Bytes #999 (0) @ WW
BID : 13290_K3CHB
Read: GUEST
Subj: AX.25 PERSONAL MAILBOX #!/bin/bash
Path: IZ3LSV<ED1ZAC<F1OYP<KE0GB<K3CHB
Sent: 210731/0757Z @:K3CHB.#EPA.PA.US.NOAM #:13290 [Camp Hill] $:13290_K3CHB
From: K3CHB@K3CHB.#EPA.PA.US.NOAM
To  : LINUX@WW

#!/bin/bash
# Forked from: https://github.com/AaronJackson/ax25hacks
# MODIFIED BY: Jimmy Capizzi, K3CHB
# DATE: 07/31/2021
# E-MAIL: k3chb@k3chb.ampr.org
#         jimmy.capizzi@gmail.com
#
# BASH AX.25 PERSONAL MAILBOX -- What more do you really need?

DIR=~/ax25mail
CALL=$1
DATE=`date '+%d%m%Y_%H%M%S'`

mkdir -p $DIR/MAIL
mkdir -p $DIR/KILL

cat <<EOF
----------------------------------------------------------------------
   ____   _    ____ _  _______ _____   ____      _    ____ ___ ___  
  |  _ \ / \  / ___| |/ / ____|_   _| |  _ \    / \  |  _ \_ _/ _ \ 
  | |_) / _ \| |   | ' /|  _|   | |   | |_) |  / _ \ | | | | | | | |
  |  __/ ___ \ |___| . \| |___  | |   |  _ <  / ___ \| |_| | | |_| |
  |_| /_/   \_\____|_|\_\_____| |_|   |_| \_\/_/   \_\____/___\___/ 
                    K3CHB-1 - Camp Hill, PA - NET105
----------------------------------------------------------------------
Welcome $CALL, type [?] for Help.
EOF

while echo -n "(1) K3CHB PMS> " && read cmd arg; do
    echo
    case $cmd in
        L*|l*)
            echo -e "No\tStatus\tTo\tFrom\tDate    \tTime\tSubject"
            grep -rm1 -e "${CALL^^}" -e "ALL" "$DIR/MAIL" |  \
               while read x ; do
                fname=$(echo "$x" | awk -F':' '{ print $1 }')
		fname=$(basename "$fname")
                status=$(echo "$fname" | awk -F'.' \
                    '{ print $3=="r"?"Read":"Unread" } ')
                num=$(echo "$fname" | awk -F'.' '{ print $2 }')
		props=$(echo "$x" | awk -F':' '{$1=""; print $0 }')
                to=$(echo "$props" | awk '{ print $2 }')
                from=$(echo "$props" | awk '{ print $1 }')
                date=$(echo "$props" | awk '{ print $3 }')
                time=$(echo "$props" | awk '{ print $4 }' | tr '-' ':')
                subj=$(echo "$props" | \
                    awk '{ $1=""; $2=""; $3=""; $4=""; print $0 }' | \
                    sed s'/^ *//g')
		echo -e "$num\t$status\t$to\t$from\t$date\t$time\t$subj"
               done
            ;;

	R*|r*)
            [ -z "$arg" ] && echo "Must specify message number." && continue
            [ ! -f "$DIR/MAIL/msg.$arg."*"" ] && echo "No such message." && continue

            header=$(cat "$DIR/MAIL/msg.$arg."*"" | awk 'NR == 1')
            to=$(echo "$header" | awk '{ print $2 }')
            from=$(echo "$header" | awk '{ print $1 }')
            date=$(echo "$header" | awk '{ print $3 " at " $4 }')

            echo -e "\n\nMessage $arg:"
            printf "%70s\n" ' ' | tr ' ' '-'
            echo "To: $to"
            echo "From: $from"
            echo "Date: $date"
            echo -e "\n"
            cat "$DIR/MAIL/msg.$arg."*"" | awk 'NR > 1'
            printf "\n%70s\n" ' ' | tr ' ' '-'
            mv "$DIR/MAIL/msg.$arg."*"" "$DIR/MAIL/msg.$arg.r" 2> /dev/null
            ;;

        S*|s*)
            [ -z "$arg" ] && echo "Must specify recipient" && continue
            nextmsg=$(ls $DIR/MAIL | sort -n | tail -n1 | \
                awk -F'.' '{ print $2+1 }')
            [ -z "$nextmsg" ] && nextmsg=1
            echo -n "Subject: " && read subj && echo
            echo "Type your message, end with /EX on a blank line"
            date=$(date +'%Y-%m-%d %H-%M')
            echo "${CALL^^} ${arg^^} $date $subj" > "$DIR/MAIL/msg.$nextmsg.u"

            while read line ; do
                [ "$line" == "/ex" ] && break
		[ "$line" == "/EX" ] && break
                echo "$line" >> "$DIR/MAIL/msg.$nextmsg.u"
            done
            echo "Message saved."
            ;;

        K*|k*)
            [ -z "$arg" ] && echo "Must specify message number." && continue
            [ ! -f "$DIR/MAIL/msg.$arg."*"" ] && echo "No such message." && continue
            [[ -n "$(grep -rm1 "ALL" "$DIR/MAIL/msg.$arg."*"")" ]] && echo "No such message." && continue

            mv "$DIR/MAIL/msg.$arg."*"" "$DIR/KILL/$CALL.$DATE" 2> /dev/null ;
            echo -e "\n\nMessage $arg has been killed."
	    ;;

        B*|b*)
            echo "Bye!"
            exit 0
            ;;

        *)
            echo -e "\nPMS commands:\n\n[L]ist messages\n[R]ead {MSG #}\n[S]end {CALLSIGN}\n[K]ill {MSG #}\n[H]elp\n[B]ye\n\n"
            ;;
    esac
done



Read previous mail | Read next mail


 08.11.2024 14:45:58lGo back Go up