get ipaddress from ping command and store it in a variable

I’m trying to write a ddns update script that deals with ip addresses. I need to store into a local variable the ipaddress from the output of the ping command like

/ping google.com count=1
SEQ HOST                                     SIZE TTL TIME  STATUS                        
    0 216.58.204.142                             56 113 45ms
    sent=1 received=1 packet-loss=0% min-rtt=45ms avg-rtt=45ms max-rtt=45ms

I understand that the script should look something like

:local ipaddress [/ping google.com count=1]

but I’m newbie and I don;t know how to parse the output into a variable.
Help will be very much appreciated.

Hi rzto, “ping” command is not used for resolving domains. You should go with “resolve”, for example:

:local ipaddress [:resolve google.com]

Che,
thanks very much for the answer and the solution.
Since my post I’ve learned that as well, however you were faster!
What a rookie mistake on my behalf at 64!
Thanks again.
PS How do I mark the topic SOLVED?