How to create a new file using Mikrotik routers scripts

How do I create a new file using a script on Mikrotik Routerboard (Router OS 6.30)?

+3


source to share


1 answer


UPDATE: These solutions don't work either. It seems impossible to create a file and edit it (/ file) during one script call. I don't know why, but the only working solution is to run the custom build script twice (first creates the file and the second edits it).

This simple task took a long time. There is no official way, just some ugly workarounds. The basic idea is to create a file using some kind of export operation (or fetch from a network operation) and then dump the created file.

Another problem is that multiple commands in the same script file somehow cannot use the generated file id. So instead of:

/file print file=newFile; /file set newFile contents=""

      



you should use:

/file print file=newFile; /file set [find name="newFile"] contents=""

      

Note that the first command simply exports a list of all files, while the second dumps its contents.

+3


source







All Articles