Community discussions

MikroTik App
 
obadaabdullah
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 71
Joined: Wed Jan 08, 2014 7:41 pm

help in writing file

Tue Apr 15, 2014 9:38 am

i'v got this script :

:foreach tmpI in=[/ip hotspot user find where (limit-bytes-total > 0)] do={
:local tmpName value=[/ip hotspot user get $tmpI value-name=name];
:local tmpLimitTotal value=[/ip hotspot user get $tmpI value-name=limit-bytes-total];
:local tmpIn value=[/ip hotspot user get $tmpI value-name=bytes-in];
:local tmpOut value=[/ip hotspot user get $tmpI value-name=bytes-out];
:local tmpRemaining value=($tmpLimitTotal - ($tmpIn + $tmpOut));
:local tmpMessage value=("User: ".$tmpName.", Limit Total: ".$tmpLimitTotal.", Used In: ".$tmpIn.", Used Out: ".$tmpOut.", Remaining Total:".$tmpRemaining);
:if ([/ip hotspot user get $tmpI value-name=disabled]) do={:set tmpMessage value=("USER DISABLED: ".$tmpMessage);};
:if ($tmpRemaining < 1) do={:set tmpMessage value=("USER OUT OF BYTES: ".$tmpMessage);};
:log info message=$tmpMessage;
/file set x.txt contents=$tmpMessage
}

the result on log is great
but i get only the last value in my txt file
what to do to write every value in on line in my txt file??
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 2954
Joined: Tue Feb 25, 2014 12:49 pm
Location: Capalbio, Tuscany, Italy

Re: help in writing file

Tue Apr 15, 2014 10:17 am

It's one of my script posted on this forum... :lol:
http://forum.mikrotik.com/viewtopic.php?f=9&t=83813

The file contents is limited to 4096 byte. You not easy get help because existing this limit. STOP.

If this limit are not a problem for you: you can not redefine the contents of file, if you not previously add the old content:
:foreach tmpI in=[/ip hotspot user find where (limit-bytes-total > 0)] do={
:local tmpName value=[/ip hotspot user get $tmpI value-name=name];
:local tmpLimitTotal value=[/ip hotspot user get $tmpI value-name=limit-bytes-total];
:local tmpIn value=[/ip hotspot user get $tmpI value-name=bytes-in];
:local tmpOut value=[/ip hotspot user get $tmpI value-name=bytes-out];
:local tmpRemaining value=($tmpLimitTotal - ($tmpIn + $tmpOut));
:local tmpMessage value=("User: ".$tmpName.", Limit Total: ".$tmpLimitTotal.", Used In: ".$tmpIn.", Used Out: ".$tmpOut.", Remaining Total:".$tmpRemaining);
:if ([/ip hotspot user get $tmpI value-name=disabled]) do={:set tmpMessage value=("USER DISABLED: ".$tmpMessage);};
:if ($tmpRemaining < 1) do={:set tmpMessage value=("USER OUT OF BYTES: ".$tmpMessage);};
:log info message=$tmpMessage;
/file set x.txt contents=([/file get x.txt contents]."\r\n".$tmpMessage);
}
I'm Italian, not English. Sorry for my imperfect grammar.
 
obadaabdullah
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 71
Joined: Wed Jan 08, 2014 7:41 pm

Re: help in writing file

Tue Apr 15, 2014 11:47 pm

It's one of my script posted on this forum... :lol:
http://forum.mikrotik.com/viewtopic.php?f=9&t=83813

The file contents is limited to 4096 byte. You not easy get help because existing this limit. STOP.

If this limit are not a problem for you: you can not redefine the contents of file, if you not previously add the old content:
:foreach tmpI in=[/ip hotspot user find where (limit-bytes-total > 0)] do={
:local tmpName value=[/ip hotspot user get $tmpI value-name=name];
:local tmpLimitTotal value=[/ip hotspot user get $tmpI value-name=limit-bytes-total];
:local tmpIn value=[/ip hotspot user get $tmpI value-name=bytes-in];
:local tmpOut value=[/ip hotspot user get $tmpI value-name=bytes-out];
:local tmpRemaining value=($tmpLimitTotal - ($tmpIn + $tmpOut));
:local tmpMessage value=("User: ".$tmpName.", Limit Total: ".$tmpLimitTotal.", Used In: ".$tmpIn.", Used Out: ".$tmpOut.", Remaining Total:".$tmpRemaining);
:if ([/ip hotspot user get $tmpI value-name=disabled]) do={:set tmpMessage value=("USER DISABLED: ".$tmpMessage);};
:if ($tmpRemaining < 1) do={:set tmpMessage value=("USER OUT OF BYTES: ".$tmpMessage);};
:log info message=$tmpMessage;
/file set x.txt contents=([/file get x.txt contents]."\r\n".$tmpMessage);
}
thanks
yeh it's your answer and i asked you there but you didn't answer ... see it again

Who is online

Users browsing this forum: Baidu [Spider] and 15 guests