python3 -m venv my-venv 新建虚拟环境
my-venv/bin/pip install wxpusher --trusted-host mirrors.aliyun 虚拟环境安装wxpusher
source /root/wxPusher/my-venv/bin/activate 激活虚拟环境
新建一个sh nano wx.sh 启动python3虚拟环境,并执行python3 /root/ts.py 执行结束后关闭虚拟环境
#!/bin/bash
echo 'ALERT - Root Shell Access (ServerName) on:' `date` `who` > 1.txt
source /root/wxPusher/my-venv/bin/activate
python3 /root/ts.py
deactivate
新建一个ts.py 主要用wxpusher实现微信推送
import requests
from wxpusher import WxPusher # https://github/wxpusher/wxpusher-sdk-python
with open('/root/1.txt', 'r') as file:
# 读取文件内容
content = file.read()
app_token = 'AT_******' # 本处改成自己的应用 APP_TO>
uid_myself = 'UID_********' # 本处改成自己的 UID
def wxpusher_send(msg):
"""利用 wxpusher 的 python SDK ,实现微信信息的发送"""
result = WxPusher.send_message(msg,
uids=[uid_myself,],
topic_ids=[topic_ids,],
token=app_token,
summary=msg[:99]) # 限定99个字符以内长度
return result
def main(msg):
result = wxpusher_send(msg)
# print(result)
if __name__ == '__main__':
main(content)
在/root目录
nano .bashrc 在最后添加以下,主要作用 当root登陆时,执行bash wx.sh 实现wxpusher推送。
if [ "$(id -u)" = "0" ]; then
bash wx.sh
fi
python3 -m venv my-venv 新建虚拟环境
my-venv/bin/pip install wxpusher --trusted-host mirrors.aliyun 虚拟环境安装wxpusher
source /root/wxPusher/my-venv/bin/activate 激活虚拟环境
新建一个sh nano wx.sh 启动python3虚拟环境,并执行python3 /root/ts.py 执行结束后关闭虚拟环境
#!/bin/bash
echo 'ALERT - Root Shell Access (ServerName) on:' `date` `who` > 1.txt
source /root/wxPusher/my-venv/bin/activate
python3 /root/ts.py
deactivate
新建一个ts.py 主要用wxpusher实现微信推送
import requests
from wxpusher import WxPusher # https://github/wxpusher/wxpusher-sdk-python
with open('/root/1.txt', 'r') as file:
# 读取文件内容
content = file.read()
app_token = 'AT_******' # 本处改成自己的应用 APP_TO>
uid_myself = 'UID_********' # 本处改成自己的 UID
def wxpusher_send(msg):
"""利用 wxpusher 的 python SDK ,实现微信信息的发送"""
result = WxPusher.send_message(msg,
uids=[uid_myself,],
topic_ids=[topic_ids,],
token=app_token,
summary=msg[:99]) # 限定99个字符以内长度
return result
def main(msg):
result = wxpusher_send(msg)
# print(result)
if __name__ == '__main__':
main(content)
在/root目录
nano .bashrc 在最后添加以下,主要作用 当root登陆时,执行bash wx.sh 实现wxpusher推送。
if [ "$(id -u)" = "0" ]; then
bash wx.sh
fi