How to create a new file by script on Mikrotik Routerboard (Router OS 6.30)?
UPDATE: This solutions also does not work well. It seems to be impossible to create a file and edit (/file set) it during one script call. I have no idea why, but only working solution is to run special create script two times (first creates a file and second edits it).
This easy task took me long time to solve. There is no official way, only some ugly workarounds. The main idea is create a file using some export operation (or fetch from network operation) and then flush created file.
Another problem is that multiple commands in one script file somehow cannot use created file's identifier. So instead of:
/file print file=newFile; /file set newFile contents=""
you must use:
/file print file=newFile; /file set [find name="newFile"] contents=""
Notice that first command just exports list of all files and second one flushes its content.