Community discussions

MikroTik App

Search found 41 matches

by rosa
Wed Mar 20, 2024 12:02 pm
Forum: Scripting
Topic: Can I clear the contents of the specified counter with a single command?
Replies: 0
Views: 1702

Can I clear the contents of the specified counter with a single command?

For example, under the sub item PPP>Interface>Link Downs, should the content be a counter?
How to batch clear it? Between pppoe-out1 and pppout100?
by rosa
Fri Mar 08, 2024 5:13 am
Forum: Scripting
Topic: How can batch PPPOE speed measurement be achieved? And display the uplink and downlink bandwidth?
Replies: 1
Views: 1285

How can batch PPPOE speed measurement be achieved? And display the uplink and downlink bandwidth?

I once saw a video online where PPPOE batch speed measurement can be performed in ROS. May I ask how experts can achieve this operation? Although ROS has related tools, I don't have a high bandwidth for building servers. If I could use resources like {speedtest. net} in ROS in bulk, it would be very...
by rosa
Mon Feb 05, 2024 11:46 am
Forum: Scripting
Topic: How should the local variable be called in if? [SOLVED]
Replies: 11
Views: 7879

Re: How should the local variable be called in if? [SOLVED]

Instead of insisting with useless ";", understand that all variables, local and global, must be defined at the start of the script, not on subsection. { :local q 0 :local yys 134 :local gsd 1936 :if ([:len [/file find where name="Save$yys$"gsd".txt"] ] > 0) do={ :set q...
by rosa
Mon Feb 05, 2024 9:45 am
Forum: Scripting
Topic: How should the local variable be called in if? [SOLVED]
Replies: 11
Views: 7879

Re: How should the local variable be called in if? [SOLVED]

I modified the above code but it still doesn't work. Is it a bug in ROS? No. The issue is the "1" in "/file get 1 content" (or, /file get "1" content, both same). What using a numeric (or string that is a number) in "get" does is tell it to get the file at in...
by rosa
Mon Feb 05, 2024 6:22 am
Forum: Scripting
Topic: How should the local variable be called in if? [SOLVED]
Replies: 11
Views: 7879

Re: How should the local variable be called in if? [SOLVED]

Thats because you are using the 'local' type which confines variables to the scope they are created within (and scopes deeper inside) but cannot exist outside of that scope. Thus as you've found it doesn't exist outside of the 'if' statement Use :global instead of :local or place the :log command i...
by rosa
Mon Feb 05, 2024 4:51 am
Forum: Scripting
Topic: How should the local variable be called in if? [SOLVED]
Replies: 11
Views: 7879

Re: How should the local variable be called in if? [SOLVED]

Thats because you are using the 'local' type which confines variables to the scope they are created within (and scopes deeper inside) but cannot exist outside of that scope. Thus as you've found it doesn't exist outside of the 'if' statement Use :global instead of :local or place the :log command i...
by rosa
Mon Feb 05, 2024 3:51 am
Forum: Scripting
Topic: How should the local variable be called in if? [SOLVED]
Replies: 11
Views: 7879

Re: How should the local variable be called in if? [SOLVED]

:log warning [$q] should not be: :log warning "$q" [] execute cmd/function, but you have a string/num. This is not the root cause, I just want to assign a value to the variable q and found that it is normal within IF! But it cannot be called outside of IF!!!? So use: log warning to see if...
by rosa
Sun Feb 04, 2024 3:52 pm
Forum: Scripting
Topic: How should the local variable be called in if? [SOLVED]
Replies: 11
Views: 7879

Re: How should the local variable be called in if? [SOLVED]

{
:if ([:len [/file find name=1.txt ]] > 0) do={
:local q [/file get "1" contents]
} else={
/file print file=1
:delay 2
:local q 0
}
:log warning [$q] ;
}
It still doesn't work, my ROS is ROS_ Long term v6.49.10
by rosa
Sun Feb 04, 2024 11:23 am
Forum: Scripting
Topic: How should the local variable be called in if? [SOLVED]
Replies: 11
Views: 7879

How should the local variable be called in if? [SOLVED]

:if ([:len [/file find name=1.txt ]] > 0) do={
:local q [/file get "1" contents]
} else={
/file print file=1
:delay 2
:local q 0
}

:log warning [$q] ;
This code cannot run as expected, and the value of variable q is empty outside?
May I ask how to rewrite it?
by rosa
Sun Feb 04, 2024 6:29 am
Forum: Scripting
Topic: How to export a backup of a script separately and restore it? [SOLVED]
Replies: 2
Views: 6732

How to export a backup of a script separately and restore it? [SOLVED]

I used the command [system script export file=script.rsc] to export all scripts to a backup file. How should I restore it? When I use the Restore function of files to restore, it will prompt: Do you want to restore configuration and reboot? After clicking Yes, a prompt will appear: Couldn't restore ...
by rosa
Sun Feb 04, 2024 5:54 am
Forum: Scripting
Topic: Can you control the length of the generated string? In ROS 6.XX.
Replies: 3
Views: 1539

Re: Can you control the length of the generated string? In ROS 6.XX.

Inspired by you, 01-09 has been resolved! But there are still some issues with 00, SNA0000000-SNA0099999
by rosa
Sun Feb 04, 2024 5:20 am
Forum: Scripting
Topic: Can you control the length of the generated string? In ROS 6.XX.
Replies: 3
Views: 1539

Re: Can you control the length of the generated string? In ROS 6.XX.

Oh! Great God~~I may not have described it properly. The character prefix I want to get is SNA00/SNA01/SNA02... SNA09 and then concatenated with complete characters such as SNA000000-SNA009999/SNA100000-SNA0199999/SNA0900000-SNA0999999. The last 5 digits range from 00000 to 99999, with only 100000 r...
by rosa
Wed Jan 31, 2024 4:56 am
Forum: Scripting
Topic: Can you control the length of the generated string? In ROS 6.XX.
Replies: 3
Views: 1539

Can you control the length of the generated string? In ROS 6.XX.

:local num 00 ; for p from=0 to=99999 do={ /interface pppoe-client set pppoe-out1 comment=("SNA".$num+$p) :delay 2 } In a script like this, how can the content of the comment be changed to something like SNA00000, SNA00000 1, until SNA0099999. This way? Can't we just use addition directly,...
by rosa
Mon Jan 22, 2024 3:52 pm
Forum: Scripting
Topic: Questions about generating valid random MAC? [SOLVED]
Replies: 17
Views: 8576

Re: Questions about generating valid random MAC? [SOLVED]

or directly
:local t [$rndMAC]
Well, I've read your post and understood it~Thank you, great god~
by rosa
Mon Jan 22, 2024 12:49 pm
Forum: Scripting
Topic: Questions about generating valid random MAC? [SOLVED]
Replies: 17
Views: 8576

Re: Questions about generating valid random MAC? [SOLVED]

:local t ;
:set t [$rndMAC] ;
by rosa
Mon Jan 22, 2024 11:37 am
Forum: Scripting
Topic: Questions about generating valid random MAC? [SOLVED]
Replies: 17
Views: 8576

Re: Questions about generating valid random MAC? [SOLVED]

00:00:00.4 = 400ms What are the benefits of your writing style? In what sense? I'm confused. May I ask for your advice? This is why the forum is here, anyone can answer you. Sorry~Some sentences are due to translation software issues, which may have caused you to misunderstand. Thank you again and ...
by rosa
Mon Jan 22, 2024 11:08 am
Forum: Scripting
Topic: Questions about generating valid random MAC? [SOLVED]
Replies: 17
Views: 8576

Re: Questions about generating valid random MAC? [SOLVED]

You use the script on x86 or CHR? There is no random number generator on v6, and using an extremely fast CPU produces the same number. I add one artificious delay on previous sript (please remove quoted scripts on your post) that apparently on my CHR/x86 fix the problem (and work on both v6 and v7)...
by rosa
Mon Jan 22, 2024 5:39 am
Forum: Scripting
Topic: Questions about generating valid random MAC? [SOLVED]
Replies: 17
Views: 8576

Re: Questions about generating valid random MAC? [SOLVED]

I have decided to choose V6.49.10. In this version, I would like to ask the forum experts how to use the most concise script to generate a valid random MAC? Forget the endless writings of @vingjfg who doesn't read my posts, so he doesn't know that simply 2 lines are enough to generate MAC address w...
by rosa
Mon Jan 22, 2024 5:15 am
Forum: Scripting
Topic: Questions about generating valid random MAC? [SOLVED]
Replies: 17
Views: 8576

Re: Questions about generating valid random MAC? [SOLVED]

Thank you very much for your sample code~It's just V7. If [: rndnum] and [: rndstr] can be downloaded and used in V6, it would be very convenient! But I think it's unlikely~
by rosa
Sun Jan 21, 2024 7:34 am
Forum: Scripting
Topic: Questions about generating valid random MAC? [SOLVED]
Replies: 17
Views: 8576

Re: Questions about generating valid random MAC? [SOLVED]

Locally administered unicast address vs. global unique unicast address. 0,4,8,C vs. 2,6,A,E See: https://developer.epages.com/blog/tech-stories/how-to-generate-mac-addresses/ Thank you very much for your connection introduction~ [0..F][0|4|8|C] - global unique unicast [0..F][1|5|9|D] - global uniqu...
by rosa
Sun Jan 21, 2024 6:38 am
Forum: Scripting
Topic: Questions about generating valid random MAC? [SOLVED]
Replies: 17
Views: 8576

Re: Questions about generating valid random MAC? [SOLVED]

Hi Rosa, Regarding the structure of a MAC address, the 2 constraints are: The LSB ("bit 0") of the first byte is 0 for a unicast address, 1 for a multicast address The next bit ("bit 1") of the first byte is 0 for a globally unique address and 1 for a locally administered addres...
by rosa
Sat Jan 20, 2024 5:54 pm
Forum: Scripting
Topic: Questions about generating valid random MAC? [SOLVED]
Replies: 17
Views: 8576

Re: Questions about generating valid random MAC? [SOLVED]

:local Hex "0123456789ABCDEF" ;
:local 2st "26AE" ;
by rosa
Sat Jan 20, 2024 5:36 pm
Forum: Scripting
Topic: Questions about generating valid random MAC? [SOLVED]
Replies: 17
Views: 8576

Questions about generating valid random MAC? [SOLVED]

Due to the insufficient support for Chinese characters in the v7 version of the script, and the fact that characters such as "[" and "]" are also randomly recognized as underscores, and the script is prone to crashes, I have decided to choose V6.49.10. In this version, I would li...
by rosa
Thu Jan 18, 2024 3:36 am
Forum: Scripting
Topic: Can the content written to the file be added? [SOLVED]
Replies: 17
Views: 8217

Re: Can the content written to the file be added? [SOLVED]

on some 7.13.something is 64KB use /interface pppoe-client export file=exportuserandpassword the export is "dirty" of other values, but export all users. [/interface pppoe client export file] This feature is not sufficient~It exports all information, I just want the value that can success...
by rosa
Wed Jan 17, 2024 4:02 am
Forum: Scripting
Topic: Correctly determine the status of PPPOE connection?
Replies: 2
Views: 1530

Re: Correctly determine the status of PPPOE connection?

Flip the forum and watch the discussion with the experts~I solved it myself~

:if (:typeof [([/interface pppoe-client monitor $pppoename once as-value]->"status")] = "disconnected") do={}
by rosa
Wed Jan 17, 2024 4:01 am
Forum: Scripting
Topic: Can the content written to the file be added? [SOLVED]
Replies: 17
Views: 8217

Re: Can the content written to the file be added? [SOLVED]

After reading the link provided by my friend below, I can understand what you're saying now. Oh, finally you understand and now I can help you without brainless cut-and-paste { :local filename "history_users_and_passwords.txt" :local pppoeArr [/interface pppoe-client print detail as-value...
by rosa
Wed Jan 17, 2024 3:52 am
Forum: Scripting
Topic: Can the content written to the file be added? [SOLVED]
Replies: 17
Views: 8217

Re: Can the content written to the file be added? [SOLVED]

Can multiple results be stored in the same file? Is HTTP or FTP okay? Or can it only be FTP? Can you provide some sample scripts? 1) Yes, you can save several results in the same file: see example in my previous post. 2) I have only tested it by FTP and it works. 3) Example of script using FTP # FT...
by rosa
Tue Jan 16, 2024 5:18 pm
Forum: Scripting
Topic: Can the content written to the file be added? [SOLVED]
Replies: 17
Views: 8217

Re: Can the content written to the file be added? [SOLVED]

Thank you for your script example, but this is not what I want. My script loop will produce some results, and my main purpose is to save these results to a file because saving to a file can prevent sudden power outages from time to time. Besides/file set, is there any other good way? I store my sen...
by rosa
Tue Jan 16, 2024 3:57 pm
Forum: Scripting
Topic: How to read text content exceeding 10000 lines?
Replies: 3
Views: 1544

Re: How to read text content exceeding 10000 lines?

Have you read at least the existing part of the manuals regarding scripting and the topics already present on the forum that talk about file management? After reading about the relevant connection you wrote, the maximum size is 64KB, so this plan has been abandoned. Using another method, thank you~!
by rosa
Tue Jan 16, 2024 3:56 pm
Forum: Scripting
Topic: Can the content written to the file be added? [SOLVED]
Replies: 17
Views: 8217

Re: Can the content written to the file be added? [SOLVED]

Sorry, maybe you didn't understand what I meant! So if you can't do something, is it my fault that I don't understand you? I'm sorry, but as usual, instead of trying to understand how it should be done, you want to do it the way you think it should be done, so I can't help you understand how it sho...
by rosa
Tue Jan 16, 2024 3:52 pm
Forum: Scripting
Topic: Can the content written to the file be added? [SOLVED]
Replies: 17
Views: 8217

Re: Can the content written to the file be added? [SOLVED]

/system clock :local dt "$[get date] $[get time]" :local filename "datetime.txt" /file :if ([:len [find where name="flash" and type="disk"]] = 1) do={:set filename "flash/$filename"} :if ([:len [find where name=$filename]] = 0) do={print file="...
by rosa
Tue Jan 16, 2024 3:48 pm
Forum: Scripting
Topic: Can the content written to the file be added? [SOLVED]
Replies: 17
Views: 8217

Re: Can the content written to the file be added? [SOLVED]

/file print file=result.txt /file set [find name="result.txt"] contents=[/interface pppoe-client get [find name=pppoe-out1] password] ------------------------------------------------------------------------------------------------------------------------------------------------------- A s...
by rosa
Tue Jan 16, 2024 5:59 am
Forum: Scripting
Topic: Correctly determine the status of PPPOE connection?
Replies: 2
Views: 1530

Correctly determine the status of PPPOE connection?

PPPOE dialing may encounter a situation where the (status) column is [disconnected] during connection. How to correctly determine this in the script? When this situation occurs, perform the operation of replacing the MAC.
by rosa
Tue Jan 16, 2024 4:38 am
Forum: Scripting
Topic: Can the content written to the file be added? [SOLVED]
Replies: 17
Views: 8217

Re: Can the content written to the file be added? [SOLVED]

Sorry, maybe you didn't understand what I meant! What I mean is adding content to a text file as the second line, is this feasible? /file set [find name="result.txt"] contents=[/interface pppoe-client get [find name=pppoe-out1] password+"<CR><LF>"] /file set [find name="resu...
by rosa
Mon Jan 15, 2024 4:38 pm
Forum: Scripting
Topic: Can the content written to the file be added? [SOLVED]
Replies: 17
Views: 8217

Can the content written to the file be added? [SOLVED]

/file print file=result.txt /file set [find name="result.txt"] contents=[/interface pppoe-client get [find name=pppoe-out1] password] ------------------------------------------------------------------------------------------------------------------------------------------------------- A sc...
by rosa
Mon Jan 15, 2024 9:57 am
Forum: Scripting
Topic: How to read text content exceeding 10000 lines?
Replies: 3
Views: 1544

Re: How to read text content exceeding 10000 lines?

For example, the text file containing numbers is N001.txt, and the size of this file is 87.8 KB (89998 bytes)
by rosa
Mon Jan 15, 2024 6:19 am
Forum: Scripting
Topic: How to read text content exceeding 10000 lines?
Replies: 3
Views: 1544

How to read text content exceeding 10000 lines?

I am preparing a test script to read a line of content from a text file and modify the user and pass parameters of pppoe-out1 for dialing testing! If successful, it will be written to a result file. Can this operation be implemented using a script? I am a beginner in ROS scripting. Do you have any e...