Community discussions

MikroTik App
 
User avatar
quotengrote
newbie
Topic Author
Posts: 33
Joined: Sun May 16, 2021 1:20 pm

invalid internal item number

Wed Oct 05, 2022 10:35 am

Hi,

when i set a variable like:
:global xx "pppoe-out-fb"
i cant use it in this where question:
/ip/address/get [find where interface "$xx" ]
invalid internal item number
Where is the problem?

Device:
/system/resource> print 
                   uptime: 3w1d18h4m48s
                  version: 7.6beta6 (development)
               build-time: Sep/07/2022 09:06:03
         factory-software: 7.0.4
              free-memory: 799.4MiB
             total-memory: 1024.0MiB
                      cpu: ARM64
                cpu-count: 4
            cpu-frequency: 350MHz
                 cpu-load: 18%
           free-hdd-space: 481.9MiB
          total-hdd-space: 513.0MiB
  write-sect-since-reboot: 74548
         write-sect-total: 995885
               bad-blocks: 0%
        architecture-name: arm64
               board-name: RB5009UG+S+
                 platform: MikroTik
Wishes
mg
 
User avatar
eworm
Forum Veteran
Forum Veteran
Posts: 979
Joined: Wed Oct 22, 2014 9:23 am
Location: Oberhausen, Germany
Contact:

Re: invalid internal item number

Wed Oct 05, 2022 7:20 pm

Two (possible) issues:
  • You are missing an equal sign...
  • Your interface may have no or more than one address...
MTCNA # 2111NA7836 | MTCRE # 2202RE4756 | MTCTCE # 2202TCE5043
Manage RouterOS scripts and extend your devices' functionality: RouterOS Scripts
For contact join the RouterOS-Scripts Telegram group!
 
User avatar
quotengrote
newbie
Topic Author
Posts: 33
Joined: Sun May 16, 2021 1:20 pm

Re: invalid internal item number

Wed Oct 05, 2022 9:11 pm

With ROS6 this Syntax works as expected.
 
msatter
Forum Guru
Forum Guru
Posts: 2706
Joined: Tue Feb 18, 2014 12:56 am
Location: Netherlands / Nīderlande

Re: invalid internal item number

Wed Oct 05, 2022 9:53 pm

I use a regualar expression to match. That is the ~ sign instead of a = .

The searched interface name has to be also unique or there will no match. If you have two PPPoE (pppoe-in pppoe-out) then matching on pppoe does not cut. You have to match on the difference and the shortest one is "in" or "out" . pppoe alone will not match and so no result.
:local xx "pppoe"; :put [typeof $xx]; :put [/ip/address/get [find interface~$xx]]
I use :local and it display the type of the variable. That is in this case a string (str), so no need to put the variable $xx in quotes.
[IN READ-ONLY MODE]
Loving my freedom and so, no PayPal, no Twitter, no Meta/Facebook/Instagram/WhatsApp, no Apple and no Alphabet/Google, no Amazon/Cloudfront/AWS.

Running: RouterOS 7.5.11 and 7.2.1 / Winbox 3.37 64bits
 
User avatar
quotengrote
newbie
Topic Author
Posts: 33
Joined: Sun May 16, 2021 1:20 pm

Re: invalid internal item number

Wed Oct 05, 2022 10:08 pm

Same error on ROS7; with ROS6 it works as expected.
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 6770
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: invalid internal item number

Wed Oct 05, 2022 11:32 pm

Returned type is an array of a single element, get command does not accept an array, either use pick command to pick the 0 element of an array or if you are sure that there is only one element then convert array to string with :tostr command
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 8928
Joined: Tue Feb 25, 2014 12:49 pm
Location: 🇮🇹, my 💔 is in 🇺🇦

Re: invalid internal item number  [SOLVED]

Fri Oct 07, 2022 2:45 am

@quotengrote, choose your method...

All tested on v6, but I do not know any reason for wat must do not work on v7, let me know, please.

:global iface "pppoe-out-fb"
:put ([/interface pppoe-client monitor $iface once as-value]->"local-address")
# do error if interface not exist
# do not contain /xx

:global iface "pppoe-out-fb"
:put [/ip address get [:tostr [find where interface=$iface]] address]
# do error if interface not exist or if interface have multiple IPs
# contain /xx and must be removed if needed

:global iface "pppoe-out-fb"
:put [/ip address get ([find where interface=$iface]->0) address]
# do error if interface not exist or if interface have no IP
# contain /xx and must be removed if needed

# on ppp profile used, on on-up script:
:global fbIP $"local-address"
# do not contain /xx
✂ Rextended Fragments of Snippets

Vld4UmVHUkdhelJUTTJzOQ==
 
User avatar
quotengrote
newbie
Topic Author
Posts: 33
Joined: Sun May 16, 2021 1:20 pm

Re: invalid internal item number

Fri Oct 07, 2022 9:58 pm

@rextended and all

Thank you very much, all of these worked for me.

Wishes
mg

Who is online

Users browsing this forum: No registered users and 5 guests