#!/bin/bash
while true
do
result=`ping -c 1 -w 3 baidu.com | grep from -c`
if test $[result] -ne 0
then
date "+%Y-%m-%d %H:%M:%S"
echo ">network is ok."
else
curl http://xxx.xx.xx -d "username=账号&password=密码"
fi
sleep 3
done
curl -d 后边加的是post的参数
-X GET 可以传递get的参数
ping baidu.com检查网络连接是否正常。
文件改成.sh文件在linux下运行:
chmod u+x hello.sh
sh hello.sh 或 ./hello.sh