Shell realizes automatic ADSL dialing and detects connection status script sharing _linux Shell

Source: Internet
Author: User
Tags sleep

Today, my company colleagues to my entire ADSL automatic redial shell, and detect whether connected to, so as to ensure that the internal test server does not drop the net, OK, I sent the script below.

System: CentOS 5.x

Script 1:

Copy Code code as follows:

cat/root/soft_shell/auto_adsl_1.sh
#!/bin/bash
Gateway= ' ifconfig ppp0 |grep p-t-p| Cut-f ":" |cut-f 1-d ""
Inter= ' ifconfig |grep Ppp0|awk ' {print $} '
n=2
if [[$inter-eq Ppp0]]
Then
/sbin/adsl-stop
Sleep 10
/sbin/adsl-start
Sleep 20
Pkgloss= ' ping-c4 $gateway |grep ' transm ' |awk-f ', ' {print $} ' |awk ' {print '} '
if [[$pkgloss-lt $N]]
Then
echo "' Date +%y-%m-%d/%t ' The network is not stable" >>/root/adsl.txt
Else
echo "' Date +%y-%m-%d/%t ' The network is normal" >>/root/adsl.txt
Fi
Fi

Script 2:
Copy Code code as follows:

cat/root/soft_shell/auto_adsl_2.sh
#!/bin/bash
Gateway= ' ifconfig ppp0 |grep p-t-p| Cut-f ":" |cut-f 1-d ""
Inter= ' ifconfig |grep Ppp0|awk ' {print $} '
n=2
if [[$inter!= Ppp0]]
Then
/sbin/adsl-start
Sleep 20
Pkgloss= ' ping-c4 $gateway |grep ' transm ' |awk-f ', ' {print $} ' |awk ' {print '} '
if [[$pkgloss-lt $N]]
Then
echo "' Date +%y-%m-%d/%t ' The network is not stable" >>/root/adsl.txt
Else
echo "' Date +%y-%m-%d/%t ' The network is normal" >>/root/adsl.txt
Fi
Fi

PS: the function of script 2 is to detect whether ADSL dialing is connected.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.