Tue Mar 05, 2013 7:49 am
Where do I put the delay command in order that a 10 second delay is executed before each query?
The script below is supposed to send sms's to prepaid users based on data used but a sms is only sent to the 1st user then the subsequent sms's don't go through:
{
:local name
:local surname
:local usage
:local bytesin
:local bytesout
:local bytestotal
:local megstotal
:local uptimelimit
:local uptimeused
:local transferlimit
:local transferlimitMB
:local dataremaining
:local cap
:local comment
:local newcomment
:local invoice
:local newinvoice
:local lastmonth
:local monthname
:local lastwarning
:local newmonth
:local newwarning
:local percentage
:local percentile
:local warninglevel
:local warn
:local update
:local email
:local phone
:local server
:local groupname
/tool user-manager user
:foreach i in=[/tool user-manager user find customer="admin"] do={
:set name [get $i first-name]
:set surname [get $i last-name]
:set uptimelimit [get $i uptime]
:set uptimeused [get $i uptime-used]
#There is no transfer limit variable and the value is stored in comment value
:set comment [get $i comment]
:set transferlimit [:pick $comment 5 9]
:set bytesin [get $i download-used]
:set bytesout [get $i upload-used]
:set bytestotal ($bytesin + $bytesout)
:set email [get $i email]
:set phone [get $i phone]
#There is no variable for groupname hence the wireless-enc-key is used to store the group-name variable
#:set groupname [get $i wireless-enc-key]
:set groupname [:pick $comment 0 5]
:if (($groupname = "Prepd") || ($megstotal <40)) do={
:set megstotal ($bytestotal / 1000000)
:set transferlimitMB ($transferlimit)
:set percentage (($megstotal * 100) / $transferlimitMB)
:set dataremaining ($transferlimitMB-$megstotal)
/tool sms send usb3 "$phone" message= "Dear $name $surname you still have $dataremaining MB left until month end"
:log info "Sent sms to $phone $name $surname"
}
}
}