+ -
当前位置:首页 → 问答吧 → xdjm,进来瞅瞅啦……

xdjm,进来瞅瞅啦……

时间:2011-11-23

来源:互联网

我想用kshell判断一个http链接到底是通不通 我该如何判断啊?有想法说下想法,没想法的给点鼓励也行……

作者: jinjong   发布时间: 2011-11-23

Python code

[root@RHEL6A scripts]# vim py2.py
[root@RHEL6A scripts]# chmod u+x py2.py 
[root@RHEL6A scripts]# ./py2.py 
<urlopen error [Errno -2] Name or service not known>
[root@RHEL6A scripts]# more py2.py 
#!/usr/bin/env python
#coding:utf-8

import urllib2


def main():
    try:
    url='http://www.163.com'
    url='http://www.163.com'
    return1=urllib2.urlopen(url)    
    except Exception,ex:
        print ex

if __name__=='__main__':
    main()



python来
你看上面报错了就是不行,因为我的虚拟机没连internet网~~

作者: askandstudy   发布时间: 2011-11-23

引用 1 楼 askandstudy 的回复:
Python code

[root@RHEL6A scripts]# vim py2.py
[root@RHEL6A scripts]# chmod u+x py2.py
[root@RHEL6A scripts]# ./py2.py
<urlopen error [Errno -2] Name or service not known>
[root@RHEL6A scripts……

我想用Kshell,这个我用不起来额 ,写在脚本里的。

不过谢谢你操心啊……我一定会结贴的 不会忘记xd你的…… 

作者: jinjong   发布时间: 2011-11-23

Assembly code

# ./ks1.sh
website is down. Trigger the email
# more ks1.sh
#!/bin/ksh
wget -q -O /dev/null -S http://www.163.com
if [ $? = 0 ]
then
echo "website is up"
else
echo "website is down. Trigger the email"
fi



你试试看这个好不好用

作者: askandstudy   发布时间: 2011-11-23

Assembly code

#!/bin/ksh
wget -q -O /dev/null -S http://www.163.com
if [ $? = 0 ]
then
echo "website is up"
else
echo "website is down. Trigger the email"
fi



作者: askandstudy   发布时间: 2011-11-23

热门下载

更多