在Debian系统上使用Huawei E3131和HiLink通过命令行发送和接收SMS [英] Sending and receiving SMS by command line with Huawei E3131 and HiLink on a debian system

查看:213
本文介绍了在Debian系统上使用Huawei E3131和HiLink通过命令行发送和接收SMS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很长时间在互联网上搜索了有关如何在基于Debian的linux系统上使用Huawei E3131和HiLink通过命令行发送短信的指南.他们都没有工作.看来,该软件已有更新.

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向我显示以下版本:

HiLink shows the following versions to me:

  • 设备名称:E3131
  • 硬件版本:CU1E3131IM
  • 软件版本:22.521.23.00.00
  • Web前端版本:17.100.08.00.03

以下问题:如何在具有E3131的基于debian的linux系统上通过命令行发送/接收短信?

Following the question: How to send / receive sms by command line on a debian based linux system with E3131?

有一个后续问题,需要在超级用户的无头系统上设置硬件

推荐答案

3个步骤是必需的:

  1. 获取会话ID
  2. 获取令牌
  3. 发送/接收短信


第1步-获取会话ID

为了获取会话ID,我在自己的shell脚本中使用以下命令:

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

#!/bin/bash

curl -b session.txt -c session.txt http://192.168.8.1/html/index.html > /dev/null 2>&1


第2步-获取令牌

为了获得令牌,我在自己的shell脚本中使用以下命令:

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

#!/bin/bash

TOKEN=$(curl -s -b session.txt -c session.txt http://192.168.8.1/html/smsinbox.html)
TOKEN=$(echo $TOKEN | cut -d'"' -f 10)

echo $TOKEN > token.txt


第3步A部分-发送短信

最后是用于发送短信的第三个shell脚本,该脚本还调用了其他两个脚本:

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

#!/bin/bash

NUMBER=$1
MESSAGE=$2

./session.sh
./token.sh

LENGTH=${#MESSAGE}
TIME=$(date +"%Y-%m-%d %T")
TOKEN=$(<token.txt)

SMS="<request><Index>-1</Index><Phones><Phone>$NUMBER</Phone></Phones><Sca/><Content>$MESSAGE</Content><Length>$LENGTH</Length><Reserved>1</Reserved><Date>$TIME</Date></request>"

echo $SMS

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

用法是:

command phonenumber "text"


步骤3 B部分-接收短信

为了接收最近未读的短信(或者,如果不可用,则接收最近读的短信),我使用以下脚本:

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

#!/bin/bash

./session.sh
./token.sh

TOKEN=$(<token.txt)

DATA="<request><PageIndex>1</PageIndex><ReadCount>1</ReadCount><BoxType>1</BoxType><SortType>0</SortType><Ascending>0</Ascending><UnreadPreferred>1</UnreadPreferred></request>"

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


这可能不是很好的编码,但是可以.


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

这篇关于在Debian系统上使用Huawei E3131和HiLink通过命令行发送和接收SMS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆