找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 10370|回复: 5

[脚本] 提取PCC参数

[复制链接]
发表于 2021-3-4 11:36:56 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

×
脚本::put [ip fir man get [find comment="1"] per-connection-classifier]
输出结果:both-addresses-and-ports:10/0

请教,如何单独提取输出结果中both-addresses-and-ports,10,0
routeros
发表于 2021-3-5 01:04:00 | 显示全部楼层
本帖最后由 cspm333 于 2021-3-5 01:31 编辑
e_zhangiso 發表於 2021-3-4 20:02
感謝大神出手,可不可以不生成file,直接提取?

2021-03-05 00-39-28 的螢幕擷圖.png
Sorry~ /file remove prt.txt
太早移除prt.txt似乎影響字串儲存到z,x,y變數里...
改成將字串先存到變數,再移除prt.txt就沒問題了。

因為您給的題目裡有:put這個指令(列印到終端機)
所以透過:execute將終端機的文字存到prt.txt,再從prt.txt抓出字串。

若您的題目少了:put,則就簡單的多。
直接將[ip fir man get [find comment="1"] per-connection-classifier]存到變數prt就好,
不用多這個:execute儲存終端機文字到prt.txt的動作:
2021-03-05 01-00-21 的螢幕擷圖.png
  1. :local prt [ip fir man get [find comment="1"] per-connection-classifier]
  2. :local z [:pick $prt 0 [find $prt ":"]]
  3. :local x [:pick $prt ([find $prt ":"]+1) [find $prt "/"]]
  4. :local y [:pick $prt ([find $prt "/"]+1) [:len $prt]]
  5. :put $z
  6. :put $x
  7. :put $y
复制代码

点评

热心大神,点赞!  发表于 2021-3-6 11:49
routeros
回复 1 0

使用道具 举报

发表于 2021-3-4 12:21:28 | 显示全部楼层
本帖最后由 cspm333 于 2021-3-4 12:32 编辑

:execute {:put [ip fir man get [find comment="1"] per-connection-classifier]} file=prt ; :delay 1s
:local prt [/file get prt.txt content]
/file remove prt.txt
:local z [:pick $prt 0 [find $prt ":"]]
:local x [:pick $prt ([find $prt ":"]+1) [find $prt "/"]]
:local y [:pick $prt ([find $prt "/"]+1) [find $prt "\r"]]

變數z , x , y 存的值即您要的輸出。
routeros
回复

使用道具 举报

 楼主| 发表于 2021-3-4 20:02:15 | 显示全部楼层
感谢大神出手,可不可以不生成file,直接提取?
QQ图片20210304195656.png
routeros
回复

使用道具 举报

 楼主| 发表于 2021-3-5 17:38:22 | 显示全部楼层
cspm333 发表于 2021-3-5 01:04
Sorry~ /file remove prt.txt
太早移除prt.txt似乎影響字串儲存到z,x,y變數里...
改成將字串先存到變數, ...

测试成功,感谢。
routeros
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|手机版|小黑屋|软路由 ( 渝ICP备15001194号-1|渝公网安备 50011602500124号 )

GMT+8, 2024-3-28 20:48 , Processed in 0.430274 second(s), 7 queries , Gzip On, Redis On.

Powered by Discuz! X3.5 Licensed

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表