Community discussions

MikroTik App
just joined
Topic Author
Posts: 4
Joined: Sat Oct 11, 2014 2:48 pm

Script Ping (Host To IP) to the variable.

Sat Oct 11, 2014 2:55 pm

Hi, I do not know how to write a script. Please help.
I would like to use ping to the domain.
Then assign the host IP to a variable.
:local PingResult

:set PingResult [ping count=2]
:put $PingResult
:log info $PingResult
:log info "2"

How to do that resulted in the IP:
:log info ""
User avatar
Long time Member
Long time Member
Posts: 586
Joined: Wed Nov 30, 2011 3:05 am

Re: Script Ping (Host To IP) to the variable.

Tue Oct 28, 2014 11:07 pm

To log the IP, do this:
:log info [:resolve]
I don't need any karma... I have Ιησους Χριστος!
User avatar
Forum Guru
Forum Guru
Posts: 1848
Joined: Mon Jun 16, 2014 1:13 pm
Location: Poland

Re: Script Ping (Host To IP) to the variable.

Wed Oct 29, 2014 12:08 am

IMHO better way is to "fix" IP durig test to prevent situation when could resolve to different IPs
:local PingResult
:local PingIP

:set PingIP [:resolve]
:set PingResult [ping $PingIP count=2]
:put $PingResult
:log info $PingIP
Real admins use real keyboards.

Who is online

Users browsing this forum: No registered users and 32 guests