Peters Peters - 1 year ago 801
Bash Question

Sending and receiving SMS by command line with Huawei E3131 and HiLink on a debian system

I long time searched the internet for a guide how to send sms by command line with Huawei E3131 and HiLink on a debian based linux system. All of them not worked. It seems, that there was an update on the software.

HiLink shows the following versions to me:

  • Device-Name: E3131

  • Hardware-Version: CU1E3131IM

  • Software-Version: 22.521.23.00.00

  • Web-Frontend-Version:

Following the question:

  • How to send sms?

  • How to receive sms?

Answer Source

3 steps are necessary:

  1. Get session id
  2. Get token
  3. Send / receive sms

Step 1 - Get session id

For getting the session id I use the following command in an own shell script:


curl -b session.txt -c session.txt > /dev/null 2>&1

Step 2 - Get token

For getting the token I use the following commands, also in an own shell script:


TOKEN=$(curl -s -b session.txt -c session.txt
TOKEN=$(echo $TOKEN | cut -d'"' -f 10)

echo $TOKEN > token.txt

Step 3 Part A - Send SMS

Finally a third shell script for sending the sms, which also invokes the two other scripts:




TIME=$(date +"%Y-%m-%d %T")


echo $SMS

curl -v -b session.txt -c session.txt -H "X-Requested-With: XMLHttpRequest" --data "$SMS" --header "__RequestVerificationToken: $TOKEN" --header "Content-Type:text/xml"

Usage is:

command phonenumber "text"

Step 3 Part B - Receive SMS

And for receiving the last unread sms (or, if not avaiable, the last read sms) I use the following script:





curl -b session.txt -c session.txt -H "X-Requested-With: XMLHttpRequest" --data "$DATA" --header "__RequestVerificationToken: $TOKEN" --header "Content-Type:text/xml"

This is maybe not very good coding, but it works.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download