how to get only ip from queue simple from script

Hi.
I am working in a script to get only the ip address from queue simple, but I have a bit problem

the script what I am trying for get only ip address without the netmask is
foreach i in=[queue simple find ] do={
local tmp [/queue simple get value-name=target $i]
local ip [pick $tmp 0 [:find $tmp “/”]]
put $ip}
192.168.88.2/32
192.168.88.3/32I need only this output

192.168.88.2
192.168.88.3

if I execute this command, is working:
local tmp 192.168.88.2/32; put [pick $tmp 0 [:find $tmp “/”]]
192.168.88.2

I am wrong but where?

I suggest you to read all my post with script… :slight_smile:

:local fullIP value="123.45.67.89/10";
:local onlyIP value=[:pick $fullIP -1 [:find $fullIP "/"]];

DO NOT PLACE SPACE BETWEEN “-” AND “1” on “-1”

And if you want, remember Karma…


EDIT: this is one example, remember to pass STRING variable inside fullIP, not a IP variable…

not work…

foreach o in=[queue simple find] do={
{… :local fullIP value=[queue simple get value-name=target $o]
{… :local onlyIP value=[:pick $fullIP -1 ([:len $fullIP] - 3)];
{… put $onlyIP
{… }

[admin@MikroTik] >foreach o in=[queue simple find] do={
{… :local fullIP value=[queue simple get value-name=target $o]
{… put $fullIP
{… }
192.168.88.2/32
192.168.88.3/32

Try to use correct syntax in your script, this solve the problems…

:foreach o in=[/queue simple find] do={
 :local fullIP value=[:tostr [/queue simple get $o value-name=target]];
 :local onlyIP value=[:pick $fullIP -1 [:find $fullIP "/"]];
 :put $onlyIP;
};

And remember: not all the time the target are one IP, can be also pppoe-client or another interface…

rextended - how to change Your script for:

  1. change all SimpleQueues from 192.168.xx.1 to 192.168.zz.1 (all queues from 100 to 200)
  2. change all PPPoE secrets addresses like SimpleQueues
    Tahk You.