Hi, I currently making a bash script to perform some tests in my setup.
I need to get the IP from a recently deployed machine to use to perform some ping and other.
How can I get the ping from the CLI? I can see it on the GUI but I want to make the script automated.
Thanks all.
I found that with this command:
maas $PROFILE interfaces read $SYSTEM_ID | jq β.[] | {links:.links[] |{ip:.ip_address}}β --compact-output)
I can get an output like this:
{βlinksβ:{βipβ:β10.10.10.38β}}
But how can I extract only the IP?
@jbacelo , try this:
maas $PROFILE interfaces read $SYSTEM_ID | jq '.[] | (.links[].ip_address)' | sed -e 's/^"//' -e 's/"$//'
which gives something like:
192.168.123.16
It worked great.
Thanks @billwear
1 Like
np. i can usually help with CLI + jq issues, feel free to ping me on discourse.
Pro-tip - to avoid the jq | sed
check out jq
's -r
option
$ maas $PROFILE interfaces read $SYSTEM_ID | jq -r '.[] | (.links[].ip_address)'
10.245.136.62
2 Likes
yep. nice tip, thanks @sparkiegeek .
1 Like
system
Closed
1 November 2020 15:22
9
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.