是的。如果你运行这个脚本checksitestatus.sh并使用http://google.com它会说site is up. 如果你输入http://googlex.com它会说site is down。
您必须lynx从存储库安装到:
$ sudo apt-get install lynx
Run Code Online (Sandbox Code Playgroud)
脚本(checksitestatus.sh):
#!/bin/bash
if [[ $# -eq 0 ]] ; then
echo 'Missing parameter - site to check... exiting.'
exit 0
fi
site=$1
siteisdown=$(lynx -dump $site 2>&1 | egrep 'Alert!: Unable to connect to remote host.')
if [[ "$siteisdown" ]]
then
echo "Site is down"
# any other code here
else
echo "Site is up"
# any other code here
fi
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
299 次 |
| 最近记录: |