Community discussions

MikroTik App
 
WirelessRudy
Forum Guru
Forum Guru
Topic Author
Posts: 3119
Joined: Tue Aug 08, 2006 5:54 pm
Location: Spain

"remove all lines" commando in terminal

Thu Jun 16, 2011 7:48 pm

Is there a command I can give in terminal to remove all rules at once in firewall, mangle, logging etc. etc.?
Is there also a commandt to remove for instance rule 17 to 33? (so more then 9)

Now lines have to removed one by one or by mentioning them explicit with a max. of 9 and no more at once than actually exist.

Example:
I am making a setup script that in general removes all logging and firewall rules and than build the lines I want.
Now I have to do:
/ system logging
pr
rem 0,1,2,3,4

But if the logging only has 2 or 3 rules this command is not performed.
Since it is never sure how many rules already are written I have to do each time a manual remove...
 
fewi
Forum Guru
Forum Guru
Posts: 7717
Joined: Tue Aug 11, 2009 3:19 am

Re: "remove all lines" commando in terminal

Thu Jun 16, 2011 8:21 pm

remove [find]
 
WirelessRudy
Forum Guru
Forum Guru
Topic Author
Posts: 3119
Joined: Tue Aug 08, 2006 5:54 pm
Location: Spain

Re: "remove all lines" commando in terminal

Thu Jun 16, 2011 10:28 pm

remove [find]
Sorry fewi, maybe after some time I will start to understand, but for the time being to me this is the same as a Chinese just learned the first English trying to explain me how to make bread....

"remove" I can understand, I use it in given example as "rem"

But the [find] part...
Wiki Manual: find :
:find <arg> <arg> <start> return position of substring or array element

To me it is all acadabra.
<arg> probably means I have to fill in an argument. But which in this case? And do I use the "<" and ">" parameters?
"<start>"? What does this mean? To start what? What to fill in here? Why do I need that? I already start a command by hitting the enter button?

"return position of substring or array element" ???? I stand better change to make that bread. :(

From the given Wik manual example I presume I have to fill in some value in-between the [ ] hooks embedded with " " and have to start with the word "find". But what then? And what to put in-between these " "?
Something like "all"???

All I want is to erase all present unknown numbers of my /system logging output.
I have to do this on 250+ units so it would be easy to catch it in a script I can just past into each units terminal to have it done.

In plain words my command would read:
"erase all lines in /system logging print output and set new one(s)"

How to set the new ones is clear to me, but how to remove the old ones.... (in a smart way...!)
 
fewi
Forum Guru
Forum Guru
Posts: 7717
Joined: Tue Aug 11, 2009 3:19 am

Re: "remove all lines" commando in terminal

Thu Jun 16, 2011 10:54 pm

I gave the literal command. "remove [find]" as is deletes all entries. "find" can be used for string operations, which is the manual part you found. "find" can also be used to find items on the CLI. "remove [find comment="test"]" deletes all items that have a comment of "test". "/ip firewall filter { remove [find chain="input"] }" deletes all firewall filters in the input chain. "/ip firewall nat { remove [find] }" deletes all NAT rules.

"/system logging { remove [find] }" deletes all logging entries. You can split it in two as "/system logging; remove [find]".
 
WirelessRudy
Forum Guru
Forum Guru
Topic Author
Posts: 3119
Joined: Tue Aug 08, 2006 5:54 pm
Location: Spain

Re: "remove all lines" commando in terminal

Fri Jun 17, 2011 1:48 am

Now that is what I call a helpful answer. :D
Now, for a guy with so much karma :wink: you might know the answer of the following, related:

If I set in the log to print certain message to a file on disk, and I download that file in my PC all lines in that text file have no ´return´. So it is one big soup of text.....
Do you have an idea how to edit the output of the log in a way that the log files are printed in the file with returns?
After all, in the console window they do have a return...

(I can download the file into a text editor and with search and replace try to fix it but since I have to separate two words from the search string into two separated by a ´return´ (which is an ´enter´ in most editors) this is not possible. )

Any ideas?
 
fewi
Forum Guru
Forum Guru
Posts: 7717
Joined: Tue Aug 11, 2009 3:19 am

Re: "remove all lines" commando in terminal

Fri Jun 17, 2011 4:02 am

Load the file in a decent text editor. It's just a problem with UNIX vs Windows line endings. Notepad++ works well.
 
WirelessRudy
Forum Guru
Forum Guru
Topic Author
Posts: 3119
Joined: Tue Aug 08, 2006 5:54 pm
Location: Spain

Re: "remove all lines" commando in terminal

Fri Jun 17, 2011 12:58 pm

Load the file in a decent text editor. It's just a problem with UNIX vs Windows line endings. Notepad++ works well.
hmm, it works in wordpad and ms-word I just found out...
But it doesn't work in Notepad. Not in a windows7 system nor XP.
Which is frustrating since the file comes as a .txt file and I hate wordpad and ms-word is a bit ´heavy´.
 
fewi
Forum Guru
Forum Guru
Posts: 7717
Joined: Tue Aug 11, 2009 3:19 am

Re: "remove all lines" commando in terminal

Fri Jun 17, 2011 3:51 pm

notepad++
http://notepad-plus-plus.org/download

There are other light, decent text editors for Windows out there. Or - tongue in cheek - use a real computer. UNIX based machines open UNIX line ending text files just fine by default...
 
WirelessRudy
Forum Guru
Forum Guru
Topic Author
Posts: 3119
Joined: Tue Aug 08, 2006 5:54 pm
Location: Spain

Re: "remove all lines" commando in terminal

Sat Jun 18, 2011 2:30 am

notepad++
http://notepad-plus-plus.org/download

There are other light, decent text editors for Windows out there. Or - tongue in cheek - use a real computer. UNIX based machines open UNIX line ending text files just fine by default...
:)

tnks for the suggestion.

Who is online

Users browsing this forum: Amazon [Bot], anav and 86 guests