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
}
what is this?
$downquota print
But the point is: what is get from email is correct?
All user have correctly set the email?
Sorry, miss typing it has been modified
Thank you .. but give the same result “invalid value for limit-bytes-total, an integer required”
email format “100GB@30.512M”
Some users have invalid email… or real email?
Amazing.. the script is working fine. Thank you very much
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
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 "
The schema is everytime:
G@. ???
/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…
Thank you very much for your kindness
No problem, thanks to you.
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
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