I want to make script which PING to YAHOO once each 1 minute.
If PING to YAHOO timeout more than 10 times, will do:
/ip address set [find address=“1.1.1.1/30”] disabled=yes
/tool netwatch set [find host=“1.1.1.6”] disabled=yes
/ip address set [find comment=“1”] disabled=yes
/ip address set [find comment=“2”] disabled=yes
Then if PING to YAHOO reply more than 10 times, will do:
/ip address set [find address=“1.1.1.1/30”] disabled=no
/tool netwatch set [find host=“1.1.1.6”] disabled=no
I don’t know about Linux script, so please anyone can help me for making this script.
You did not say what version of ROS you are using 2.9.xx or 3.x Which one?
Basically I think you are looking for something like this:
:if ([/ping YAHOO count=10]>X) do={
{/ip address set [find address=“1.1.1.1/30”] disabled=yes}
{/tool netwatch set [find host=“1.1.1.6”] disabled=yes}
{/ip address set [find comment=“1”] disabled=yes}
{/ip address set [find comment=“2”] disabled=yes}
}
where X = the minimum number of pings you must get back before you start to disable things. You could use also ‘<’ which would mean ‘less than’.
where YAHOO = the IP address you want to ping
The above script runs in ROS ver 3.x - the script is different for ver 2.9.xx
You can check scripts in the terminal mode of MT ROS - " /system script " and then " print " you will see your scripts and any place that ROS says there is an error in the script.
There is a manual - you need to read up on MT ROS.
What is the script to check if ping is “timeout” or “reply” ?
So if “timeout” to YAHOO, then it will run the script. Then if “reply” to YAHOO, it will run the other one.
IF works like this: :if [condition is TRUE] do={THIS} else={DO THIS IF FALSE}
So if you use this line; " :if ([/ping YAHOO count=10]>8) do= { TRUE } " then IF the number of pings received back (replies) is greater than 8 then the script will excute the TRUE portion. If the number of replies is 8 or less then it would excute the ELSE portion if it exists otherwise the IF statement is done excuting.
ping looks like this; ping IP ADDRESS ttl=10 count=4 (ttl=TTL=time to live or timeout as you call it)
mrz -
If you don’t have something to contribute then stay out of the thread - BTW he is asking for a lot more than to just watch an address and if you had bothered to read everything this fellow has posted (here and elsewhere on the forum) you’d know that…
My script is work now
But when the script ping to yahoo & google, why they can not ping in the same time ?
The script ping yahoo first then ping google.
Because I want to now the string/script if my condition like this:
if ping to yahoo AND ping to google is timeout, then script will be execute
if ping to yahoo OR ping to google is timeout, then script will be execute
Two scripts would be easier for you to handle one with the AND condition and one with OR.
:if (((([/ping YAHOO count=3 size=28]<2) && ([/ping GOOGLE count=3 size=28]<2)) || (([/ping YAHOO count=3 size=28]<2) || ([/ping GOOGLE count=3 size=28]<2)))) do={/tool netwatch set [find host=“1.2.3.4”] disabled=yes} else={/tool netwatch set [find host=“1.2.3.4”] disabled=no}
I would just do the two seperate scripts…
If both time out; AND
:if (([/ping YAHOO count=3 size=28]<2) && ([/ping GOOGLE count=3 size=28]<2)) do={/tool netwatch set [find host=“1.2.3.4”] disabled=yes} else={/tool netwatch set [find host=“1.2.3.4”] disabled=no}
If either times out; OR
:if (([/ping YAHOO count=3 size=28]<2) || ([/ping GOOGLE count=3 size=28]<2)) do={/tool netwatch set [find host=“1.2.3.4”] disabled=yes} else={/tool netwatch set [find host=“1.2.3.4”] disabled=no}
Really it seems to me all you need to do is the OR - what does it matter if they both time out if you are going to do the same thing if either times out…logically speaking of course…
But when the script ping to yahoo & google, why they can not ping in the same time ?
The script ping yahoo first then ping google.
Well I guess we need a lesson in logic…
Scripts excute linearly. One piece at a time…
In your script below:
:if (([/ping YAHOO count=3 size=28]<2) || ([/ping GOOGLE count=3 size=28]<2)) do={/tool netwatch set [find host=“1.2.3.4”] disabled=yes} else={/tool netwatch set [find host=“1.2.3.4”] disabled=no}
First to excute is Yahoo, once it is done a ‘true’ or ‘false’ value is assigned, then the script proceeds to the next part, Google, once that is done it is also assiged a ‘true/false’ value. Now the section between the outside parens (( … )) is evaluated by the :if for the || OR condition. IF either is true do={this} IF false else={this}