Community discussions

MikroTik App
 
anassar26
just joined
Topic Author
Posts: 20
Joined: Sun Aug 02, 2020 3:20 pm

Please help.. to solve invalid value " an integer required " error

Fri May 20, 2022 3:52 pm

Please help when applying the following script it gives an error “invalid value for limit-bytes-total, an integer required” and I can’t find the problem or fix it
Script :
:foreach i in=[/ip hotspot user find ] do={
:local email [/ip hotspot user get value-name=email $i ]
:local downquotamb [:tonum [:pick $email 0 3]]
:local downquota ($downquotamb * 1000)
:put $downquota
/ip h us set $i  limit-bytes-total=$downquota
}
Last edited by anassar26 on Fri May 20, 2022 3:55 pm, edited 1 time in total.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Please help.. to solve invalid value " an integer required " error

Fri May 20, 2022 3:54 pm

what is this?
$downquota print

But the point is: what is get from email is correct?
All user have correctly set the email?
 
anassar26
just joined
Topic Author
Posts: 20
Joined: Sun Aug 02, 2020 3:20 pm

Re: Please help.. to solve invalid value " an integer required " error

Fri May 20, 2022 3:59 pm

what is this?
$downquota print
Sorry, miss typing it has been modified
 
anassar26
just joined
Topic Author
Posts: 20
Joined: Sun Aug 02, 2020 3:20 pm

Re: Please help.. to solve invalid value " an integer required " error

Fri May 20, 2022 4:07 pm

Thank you .. but give the same result "invalid value for limit-bytes-total, an integer required"
email format "100GB@30.512M"
Last edited by anassar26 on Fri May 20, 2022 4:15 pm, edited 1 time in total.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Please help.. to solve invalid value " an integer required " error

Fri May 20, 2022 4:14 pm

Some users have invalid email... or real email?
 
anassar26
just joined
Topic Author
Posts: 20
Joined: Sun Aug 02, 2020 3:20 pm

Re: Please help.. to solve invalid value " an integer required " error

Fri May 20, 2022 4:18 pm

Amazing.. the script is working fine. Thank you very much
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Please help.. to solve invalid value " an integer required " error

Fri May 20, 2022 4:20 pm

If user have for example "50GB@30.512M" instead of 100G picking first 3 char result on not valid number "50G"

And assign kilobit, but must correctly add at the end "M" for Megabit
 
anassar26
just joined
Topic Author
Posts: 20
Joined: Sun Aug 02, 2020 3:20 pm

Re: Please help.. to solve invalid value " an integer required " error

Fri May 20, 2022 4:30 pm

It is possible to modify the script to get the following values ​​for each user
Suppose we need to get the following values
100G....100 gaigbytes
30D.... 30 dayes
512M... profile 512M
from email structure " 100G@30D.512M "
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Please help.. to solve invalid value " an integer required " error

Fri May 20, 2022 4:33 pm

You check this?
>>>And assign kilobit, but must correctly add at the end "M" for Megabit
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Please help.. to solve invalid value " an integer required " error  [SOLVED]

Fri May 20, 2022 4:34 pm

The schema is everytime:
<GIGA>G@<DAYS>.<PROFILE NAME> ???

/ip hotspot user
:foreach user in=[find where !default and !dynamic] do={
    :local email      [get $user email]
    :local totalquota ([:tonum [:pick $email 0 [:find $email "G"] ] ] * 1000)
    :local days       [:pick $email ([:find $email "@"] + 1) [:find $email "."] ]
    :local profile    [:pick $email ([:find $email "."] + 1) [:len $email] ]
    :if ([:typeof $totalquota] = "num") do={set $user limit-bytes-total=($totalquota."M")}

    :put "$[get $user name] limit-bytes-total=$($totalquota."M") days=$days profile=$profile"
}

Avoid "G", "@" and "." on profile name...
 
anassar26
just joined
Topic Author
Posts: 20
Joined: Sun Aug 02, 2020 3:20 pm

Re: Please help.. to solve invalid value " an integer required " error

Fri May 20, 2022 4:39 pm

Thank you very much for your kindness
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Please help.. to solve invalid value " an integer required " error

Fri May 20, 2022 4:40 pm

No problem, thanks to you.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Please help.. to solve invalid value " an integer required " error

Fri May 20, 2022 4:46 pm

I notice now: limit-bytes-total limits the sum of up + down, not only download.
Is wanted? I ask because the variable on your script is called "downquota"
and set limit-bytes-total, not limit-bytes-out
 
anassar26
just joined
Topic Author
Posts: 20
Joined: Sun Aug 02, 2020 3:20 pm

Re: Please help.. to solve invalid value " an integer required " error

Fri May 20, 2022 7:05 pm

I need to modify the last script in the form below to make it work correctly. I added some additions to meet my requirements, but I encountered some difficulties when trying the script, such as it cannot be changed.”uptime “ I also want to change my script variable to download limit
Thank you very much for your interest
I appreciate your efforts

Who is online

Users browsing this forum: No registered users and 13 guests