如何通过Mikrotik路由器的脚本创建一个新文件 [英] How to create a new file by Mikrotik routers' scripting

查看:116
本文介绍了如何通过Mikrotik路由器的脚本创建一个新文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Mikrotik Routerboard(Router OS 6.30)上通过脚本创建一个新文件?

解决方案


此解决方案也不能正常工作。在一次脚本调用期间,似乎不可能创建一个文件并编辑(/文件集)。我不知道为什么,但只有工作的解决方案是运行特殊的创建脚本两次(首先创建一个文件,第二编辑它)。

这个简单的任务花了我很长时间时间来解决。没有官方的方式,只有一些丑陋的解决方法。主要的想法是使用一些导出操作(或从网络操作获取)创建一个文件,然后刷新创建的文件。

另一个问题是一个脚本文件中的多个命令以某种方式不能使用创建的文件标识符。所以,而不是:

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

您必须使用:

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

所有文件列表和第二个刷新其内容。


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.

这篇关于如何通过Mikrotik路由器的脚本创建一个新文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆