Ping-script for maintaining Gprs connection
Quite often, operators (and providers) offer cheap Internet - or even provide an anlim.
But at us all not as at people, it is simple so can not be happiness.
Often the connection is broken or "plugged" "sticks" (when the connection does not break, but the data does not go).
Anyone who encounters this problem will be helped by a simple script-pingovalochka.
Its meaning: periodically pings the address. In the absence of ping (when the channel is "stuck" or broken), reconnection occurs.
Running this script, you can be sure of maintaining the working capacity of the connection.
1. Create a cmd file in the notebook (for example, pinger.cmd) with the following contents:
@echo off echo% date%% time% --- STARTED --- >> pinger.log set Try = 1 rem All settings are in 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 number of ping attempts set MaxPing = 5 rem pause in s set Pause = 30 rem host address for ping 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% :1 goto ping : 2 goto bad : 3 rasdial% DialName% / disconnect :4 echo% date%% time% == Exit script == >> pinger.log
In the given file it is necessary to replace MANDATORY :
- name of connection (set DialName = Life) [see name: Start - Settings - Network connections - name of your connection]
- login / password (set Login = Login set Pass = Password) - if required to establish a connection
In the given file it is necessary to replace (if desired):
- the host address that pings (set host = ya.ru)
- ping timeout (set TimeOut = 10000)
- the number of ping attempts (set MaxPing = 5) after which will reconnect
- interval of connection check (set Pause = 30)
2. Next to pinger.cmd, put "choice.com" from the choise.rar archive.
3. Run and enjoy life - pingovalka will establish a connection and will maintain it in working order.
!!! Similar script "pinger" for Linux to maintain vydelenki pinger.zip.