#!/bin/bash # tel=$1 header=$2 mes=$3 ip=XXX.XXX.XXX.XXX #IP port=Y # # !!! !!! TP_MR0=0 # TP-MR IED31=1 # IED3 UDH #... ########################################################################################################################################### # # UDH UDH=`echo $mes | recode ..U2/x2` # UCS2 UDH=`echo $UDH | sed 's/0x\|,\| //g' | sed 's/000A$//g'` TP_UD=$UDH #TP-UD - UDH=`echo -n $UDH | wc -c | gawk '{print $1}'` UDH=$(($UDH/4)) # - # tel="$tel"F"" i=`echo -n $tel | wc -c | gawk '{print $1}'` i=$(($i/2)) while [ "$i" != "0" ] do R=`echo $tel | cut --complement -b '3-12' | rev` TPTEL="$TPTEL$R" tel=`echo $tel | cut --complement -b '1-2'` i=$(($i-1)) done ########################################################################################################################################### # 70 ! if [ "$UDH" -le "70" ]; then # UCS2 TP_UDL=`echo -n $TP_UD | wc -c | gawk '{print $1}'` # XX TP_UDL=$((($TP_UDL+1)/2)) TP_UDL=`printf '%02x' $TP_UDL | sed 's/[[:lower:]]/\u&/g'` # # > TPDU=""0011000B91"$TPTEL"0008AA"$TP_UDL$TP_UD" # > # AT+CMGS= Byte=`echo -n $TPDU | cut --complement -b '1-2'` # 2 , Byte=`echo -n $Byte | wc -c | gawk '{print $1}'` Byte=$((($Byte)/2)) # . RFC2217, RAW ( sleep 2 echo "AT+CMGF=0" #1 - , 0 - PDU !!! sleep 1 echo "AT+CSCS=\"UCS2\"" # sleep 1 echo "AT+CMGS=$Byte" # sleep 1 echo -e "$TPDU\\032" # + Ctrl+Z sleep 3 # , echo -e "\\033" #ESC , sleep 3 ) | telnet $ip $port #Telnet , exit 0 ################################################################################################################################## # 70! else # , UDH=$((($UDH/67)+1)) # UDH ( 1 , 67 ) IED2=$UDH # - UDH IED2=`printf '%02x' $IED2 | sed 's/[[:lower:]]/\u&/g'` # . RFC2217, RAW ( sleep 2 echo "AT+CMGF=0" #1 - , 0 - PDU !!! sleep 1 echo "AT+CSCS=\"UCS2\"" # sleep 1 # AT+CMGS= while [ $UDH -ne 0 ]; do # UCS2 TPUD=`echo -n $TP_UD | cut --complement -b '269-100000000'` # 67 TP_UD=`echo -n $TP_UD | cut --complement -b '1-268'` # 67 , TP_MR=`printf '%02x' $TP_MR0 | sed 's/[[:lower:]]/\u&/g'` # TP-MR (00, 01 ..) IED3=`printf '%02x' $IED31 | sed 's/[[:lower:]]/\u&/g'` # - UDH UDH_TP_UD=""050003FF"$IED2$IED3$TPUD" # TP-UDL TP_UDL=`echo -n $UDH_TP_UD | wc -c | gawk '{print $1}'` # XX TP_UDL=$(($TP_UDL/2)) TP_UDL=`printf '%02x' $TP_UDL | sed 's/[[:lower:]]/\u&/g'` # TPDU=""0041"$TP_MR"0B91"$TPTEL"0008"$TP_UDL$UDH_TP_UD" # > TP_MR0=$(($TP_MR0+1)) # $TP-MR0 1 IED31=$(($IED31+1)) # UDH UDH=$(($UDH-1)) # # AT+CMGS= Byte=`echo -n $TPDU | cut --complement -b '1-2'` # 2 , Byte=`echo -n $Byte | wc -c | gawk '{print $1}'` Byte=$((($Byte)/2)) # echo "AT+CMGS=$Byte" # sleep 1 echo -e "$TPDU\\032" # + Ctrl+Z sleep 3 # , echo -e "\\033" #ESC , sleep 3 done ) | telnet $ip $port #Telnet , fi exit 0 # , , "-e" "echo"
Source: https://habr.com/ru/post/264949/
All Articles