Community discussions

MikroTik App
 
User avatar
Sertik
Member
Member
Topic Author
Posts: 435
Joined: Fri Sep 25, 2020 3:30 pm
Location: Russia, Moscow

export scripts from the repository saved under a specific owner

Mon Feb 26, 2024 7:19 pm

I just can’t solve a seemingly simple problem:

From all the scripts in the router repository, you need to select only those scripts that are saved under “owner”, for example “Sertik”, exporting them to one .rsc file

It is clear that you can cycle through the contents of the scripts under the desired owner and save them to a text file, but I want to use the command:
/system script export file=users.rsc
but it only exports all the repository scripts at once... How to solve this?
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 3431
Joined: Sun May 01, 2016 7:12 pm
Location: California

Re: export scripts from the repository saved under a specific owner

Mon Feb 26, 2024 8:04 pm

That's odd. Assuming your user is a full admin with all policies allowed... my expectation be the :export would include all scripts.

They made changes else where in script policy, so I suspect this is new. But begs the question of how to save the entire config if your admin. I think this is a bug, but did not test. Either just in export; or, if it's some intentional effort to block cross-user access by Mikrotik, it doesn't offer security since you report you loop to get the other user's scripts (which be goal in not exporting it).
 
User avatar
Sertik
Member
Member
Topic Author
Posts: 435
Joined: Fri Sep 25, 2020 3:30 pm
Location: Russia, Moscow

Re: export scripts from the repository saved under a specific owner

Mon Feb 26, 2024 8:42 pm

Dear, Amm !

I do not understand you. I repeat the question: as you know, /system script export file=myscript.rsc will save all the repository scripts in myscript.rsc Scripts stored in the router repository have different properties, including the “owner” property (creator). Is it possible to somehow select scripts by this property and save them into one .rsc file, since /system script export does this or does the ROS router not support this?

My goal is not to get another user's scripts, but to create a script file under a specific "creator" (owner), also created by me. This is convenient because when /import unpacks scripts, they appear in the repository under a specific owner, which can be called anything and the user/admin will understand where these scripts came from. I use this trick to unpack my script libraries, for example under owner "Sertik".

Now I do this manually and I have to save all the scripts, then delete all the unnecessary ones, then edit the scripts under the given owner, then do /export. And then restore your script configuration. It's long and inconvenient. I would like to automate this process.
Last edited by Sertik on Mon Feb 26, 2024 8:50 pm, edited 1 time in total.
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 3431
Joined: Sun May 01, 2016 7:12 pm
Location: California

Re: export scripts from the repository saved under a specific owner

Mon Feb 26, 2024 8:49 pm

Ah... you want to restrict :export to the current user. That's not possible.

The idea with :export is that you can re-build an entire config, so it includes other user's scripts – that is what :export should do.

:export has no filter options, other than the starting path. So a for loop around [find owner=X] only way to do what you want.
 
User avatar
Sertik
Member
Member
Topic Author
Posts: 435
Joined: Fri Sep 25, 2020 3:30 pm
Location: Russia, Moscow

Re: export scripts from the repository saved under a specific owner

Mon Feb 26, 2024 8:55 pm

It’s a pity that the Ikrotik developers didn’t think of making filters in /export... You don’t have a ready-made script or some kind of preparation that could assemble a file from individual scripts in the /export format, so that it would be correctly understood and restored by the /import command ?
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12001
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: export scripts from the repository saved under a specific owner

Tue Feb 27, 2024 12:49 am

False, already are implemented the export of specific scripts...

exceptional for v7.13.5 code

/system script export where owner=admin

or 

/system script export where name=<script name>
The problem is to import it for specific user...

*******************************

I write this to extract at least all possible commands and parameters on RouterOS:
viewtopic.php?t=199139#p1047229
Simply compare previous version(s) file(s) to last version to show new command(s) AND new parameter(s) to that command(s)...

extract from results code

[rex@tended] > $cmdtree "/system/script" 
[…]
/system/script
[…]
              export
              (a) compact
              (a) file
              (a) hide-sensitive
              (a) show-sensitive
              (a) terse
              (a) verbose
              (a) where
[…]
 
User avatar
Sertik
Member
Member
Topic Author
Posts: 435
Joined: Fri Sep 25, 2020 3:30 pm
Location: Russia, Moscow

Re: export scripts from the repository saved under a specific owner

Tue Feb 27, 2024 8:44 am

Thank you very much, Rex!
/system script export where owner=admin
This is what I needed! But the problem is that this only works in ROS 7, starting with the version you specified and does not work at all in ROS 6, since there is no "where" for /export yet...
/system script export <tab> (in ROS 6):
compact file hide-sensitive terse verbose

As you wrote. Your $cmdtree search function (for ROS 7 only but used /console/inspect) possible command parameters is also wonderful and very useful.

I need a solution that would work universally on all versions of ROS. Can you suggest such a thing?
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12001
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: export scripts from the repository saved under a specific owner

Tue Feb 27, 2024 9:49 am

On 6.x not...
 
User avatar
Sertik
Member
Member
Topic Author
Posts: 435
Joined: Fri Sep 25, 2020 3:30 pm
Location: Russia, Moscow

Re: export scripts from the repository saved under a specific owner

Tue Feb 27, 2024 1:30 pm

Surely this can be done, but you need to write a whole large script that would select scripts from the repository according to the creator (owner), process each line of them with escaping the necessary symphols and inserting control symphols (and taking into account all the nuances of this process, it is unlikely to work out without mistakes.), etc..., and then write it all into one "export" script file. But it's a lot of work... It's easier for me to assemble the necessary .rsc file manually ...

We need to switch to ROS 7 ...

Thank you, Teacher!

Who is online

Users browsing this forum: saied and 12 guests