Community discussions

MikroTik App
 
sdlostboy
just joined
Topic Author
Posts: 1
Joined: Wed Mar 30, 2022 4:41 am

Ping not working in script on 7.1.5?

Wed Mar 30, 2022 4:48 am

I'm working on a script that uses ping to check if a remote host is up. Its not working. I've found several similar examples on this forum that use ping in scripts for various things; I've loaded several of those scripts just to see if they work -- they don't.

It may be that something has changed in current RouterOS that breaks all of these?

Can someone look at my below test output and tell me why it might not work. Any thoughts would be appreciated.

-J

[admin@MikroTik] >
[admin@MikroTik] >
[admin@MikroTik] > /system/script/print from=test
Flags: I - invalid
0 name="test" owner="admin" policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon dont-require-permissions=yes last-started=mar/29/2022 18:36:41 run-count=14
source=
:if ([:ping 8.8.8.8 count=2 interval=90ms]!=2) do={:put "failed"}

**** Since 8.8.8.8 is reachable, I expect to not see the word "failed" appear when this above script is run ****

[admin@MikroTik] > /system/script/run test
Columns: SEQ, HOST, SIZE, TTL, TIME
SEQ HOST SIZE TTL TIME
0 8.8.8.8 56 117 15ms691us
1 8.8.8.8 56 117 22ms882us

failed

**** However, I do see the word failed.. even though console output clearly shows there were two responses ****

[admin@MikroTik] > :put [:ping 8.8.8.8 count=2]
Columns: SEQ, HOST, SIZE, TTL, TIME
SEQ HOST SIZE TTL TIME
0 8.8.8.8 56 117 18ms205us
1 8.8.8.8 56 117 14ms166us

**** here I try it manually on the console... there are two ping responses but no result output of the ping invocation, seemingly ****
*** below are details of my hardware and OS versions ***

[admin@MikroTik] > /system/routerboard/print
routerboard: yes
model: CCR1009-7G-1C-1S+
serial-number: 915008B5E749
firmware-type: tilegx
factory-firmware: 3.41
current-firmware: 7.1.5
upgrade-firmware: 7.1.5
[admin@MikroTik] > /system/package/print
Columns: NAME, VERSION
# NAME VERSION
0 iot 7.1.5
1 routeros 7.1.5
[admin@MikroTik] >
[admin@MikroTik] >
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3291
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: Ping not working in script on 7.1.5?

Thu Mar 31, 2022 9:00 am

Use netwatch, not ping in script:
viewtopic.php?p=922780

Who is online

Users browsing this forum: No registered users and 18 guests