Script pingovalka for maintaining Gprs-connection
Quite often, operators (and providers) offer cheap Internet - or even provide anlim.
But with us everything is not like with people, it just cannot be happiness.
Often the connection is broken or "shuts up" "sticks" (when the connection does not break, but the data does not go).
Anyone who encounters this problem will be helped by a simple ping-ping script.
Its meaning: the address periodically responds. In the absence of ping (when the channel is “stuck” or broken), reconnection occurs.
By running this script, you can be sure of maintaining a healthy connection.
1. Create a cmd-file in a notepad (for example, pinger.cmd) with the following contents:
@echo off echo% date%% time% --- STARTED --- >> pinger.log set Try = 1 rem All settings are moved to this block. rem connection name set DialName = Life rem login set Login = Login rem Password set Pass = Password rem ping timeout in ms set TimeOut = 10000 rem the number of ping attempts set MaxPing = 5 rem pause in s set Pause = 30 rem ping host address set host = ya.ru rem your phone number set PhoneNum = 80631234567 : start echo. echo start ping ping% host% -n 1 -w% TimeOut% if errorlevel = 1 goto bad goto ok : ping echo. ping% host% -n 1 -w% TimeOut% if not errorlevel = 1 goto ok set / a Try =% Try% + 1 if% Try% geq% MaxPing% goto bad goto ping : ok echo. echo ALL RIGHT goto end : bad set / a Try = 1 echo. echo BAD CONNECT echo% date%% time% -! Trouble, reconnect! - >> pinger.log rasdial% DialName% / disconnect rasdial% DialName% / phone:% PhoneNum% rasdial% DialName%% Login%% Pass% if errorlevel = 1 goto bad goto ping : end set / a Try = 1 echo. choice / C: PRDE / T: P, 30 / N Pause 30 seconds. [P] ing [R] econnect [D] isconnect [E] xit? rem echo. rem echo. goto% ERRORLEVEL% :one goto ping : 2 goto bad : 3 rasdial% DialName% / disconnect :four echo% date%% time% == Exit script == >> pinger.log
In this file you need to replace MANDATORY :
- connection name (set DialName = Life) [look at the name: Start - Settings - Network Connections - the name of your connection]
- login / password (set Login = Login set Pass = Password) - if required to establish a connection
In this file you need to replace (if desired):
- address of the host that is responding (set host = ya.ru)
- ping timeout (set TimeOut = 10000)
- the number of ping attempts (set MaxPing = 5) after which there will be reconnection
- connection check interval (set Pause = 30)
2. Next to pinger.cmd we put "choice.com" from the choise.rar archive.
3. We start and enjoy life - pingovalka will establish a connection and will maintain it in working condition.
!!! A similar script "pinger" for Linux to maintain pinger.zip highlighting.