Skip to content

Instantly share code, notes, and snippets.

@castironclay
Last active May 10, 2021 00:34
Show Gist options
  • Save castironclay/05f486cc1a75a4d90baeda638bb6fc11 to your computer and use it in GitHub Desktop.
Save castironclay/05f486cc1a75a4d90baeda638bb6fc11 to your computer and use it in GitHub Desktop.
ZTE Send public IP sms
#!/bin/bash
until ping -I usb0 -c 1 192.168.0.1 >/dev/null 2>&1; do sleep 1; done
generate_pub_ip ()
{
current_ip=$(curl ifconfig.io)
first_octet=$(echo $current_ip | awk -F "." '{print $1}')
second_octet=$(echo $current_ip | awk -F "." '{print $2}')
third_octet=$(echo $current_ip | awk -F "." '{print $3}')
fourth_octet=$(echo $current_ip | awk -F "." '{print $4}')
arr1=()
for ((i = 0; i < ${#first_octet}; i++)); do
arr1+=("003"${first_octet:$i:1})
done
arr2=()
for ((i = 0; i < ${#second_octet}; i++)); do
arr2+=("003"${second_octet:$i:1})
done
arr3=()
for ((i = 0; i < ${#third_octet}; i++)); do
arr3+=("003"${third_octet:$i:1})
done
arr4=()
for ((i = 0; i < ${#fourth_octet}; i++)); do
arr4+=("003"${fourth_octet:$i:1})
done
first_octet=()
for x in "${arr1[@]}"; do
first_octet=${first_octet}${x}
done
second_octet=()
for x in "${arr2[@]}"; do
second_octet=${second_octet}${x}
done
third_octet=()
for x in "${arr3[@]}"; do
third_octet=${third_octet}${x}
done
fourth_octet=()
for x in "${arr4[@]}"; do
fourth_octet=${fourth_octet}${x}
done
full=${first_octet}"002E"${second_octet}"002E"${third_octet}"002E"${fourth_octet}
echo $full
}
curl -i -s -k -X $'POST' \
-H $'Host: 192.168.0.1' \
-H $'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \
-H $'Origin: http://192.168.0.1' \
-H $'Referer: http://192.168.0.1/index.html' \
-H $'Connection: close' \
--data-binary $'isTest=false&goformId=SEND_SMS&notCallback=true&Number=%2B(YOUR 11 DIGIT NUMBER HERE)&&ID=-1&encode_type=GSM7_default' \
--data-binary MessageBody="$(generate_pub_ip)" \
$'http://192.168.0.1/goform/goform_set_cmd_process'
@castironclay
Copy link
Author

castironclay commented May 9, 2021

Send sms message containing current public IP address to specified phone number. Vodafone MF833V #cli #api #zte #raspberrypi #sms

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment