首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

shell脚本检测网络是不是畅通

2013-09-13 
shell脚本检测网络是否畅通前言shell脚本上传数据时,通常需要先检测网络的畅通性,今天导师指导了一个检测

shell脚本检测网络是否畅通
前言shell脚本上传数据时,通常需要先检测网络的畅通性,今天导师指导了一个检测网络畅通性的脚本,记录一下,时间紧迫,不做多余解释
代码

#检测网络链接&&ftp上传数据function networkAndFtp(){#超时时间timeout=5#目标网站target=www.baidu.com#获取响应状态码ret_code=`curl -I -s --connect-timeout $timeout $target -w %{http_code} | tail -n1`if [ "x$ret_code" = "x200" ]; then#网络畅通else#网络不畅通fi}


热点排行