找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 4456|回复: 7

[脚本] 请教个脚本问题

[复制链接]
发表于 2012-6-7 12:47:40 | 显示全部楼层 |阅读模式

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

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

×
:set x [/ip firewall mangle get [find new-connection-mark=conn-1] comment]

取new-connection-mark=conn-1的comment值到,变量X中.这句有错吗?
ros中执行不了.
routeros
发表于 2012-6-7 13:20:46 | 显示全部楼层
本帖最后由 huigezi' 于 2012-6-7 13:20 编辑

:set 是给已经定义的变量赋予新的值,前提是你已经给定义了一个值
比如:

:global a
:set a [/ip firewall mangle get [find new-connection-mark=1] comment]


这样变量a就被赋予了一个新的参数值
routeros
回复

使用道具 举报

 楼主| 发表于 2012-6-7 19:23:00 | 显示全部楼层

:local x
:set x [ip firewall mangle get [find new-connection-mark=conn-1] comment]
:log info "=========================== $x ============================="

还是执行不了,真没搞明白是什么原因.
routeros
回复

使用道具 举报

发表于 2012-6-7 19:34:48 | 显示全部楼层
本帖最后由 huigezi' 于 2012-6-7 20:03 编辑

{
:local x
:set x [ip firewall mangle get [find new-connection-mark=conn-1] comment]
:log info ( "===========================". $x." =============================")
}


这样试试
routeros
回复

使用道具 举报

 楼主| 发表于 2012-6-7 20:00:12 | 显示全部楼层
本帖最后由 hj-cdx 于 2012-6-7 20:02 编辑
huigezi' 发表于 2012-6-7 19:34
{
:local x
:set x  comment]


不能执行...

命令模式下:
[admin@test_02] > :global x                                                                 
[admin@test_02] > :set x [/ip firewall mangle get [find in-interface=pppoe-out1] comment]
no such item
[admin@test_02] >
routeros
回复

使用道具 举报

发表于 2012-6-7 20:03:36 | 显示全部楼层
/ip firewall mangle
:put [get [find new-connection-mark=conn-1 ] comment]
?
是否非条件唯一
routeros
回复

使用道具 举报

 楼主| 发表于 2012-6-7 20:15:07 | 显示全部楼层
本帖最后由 hj-cdx 于 2012-6-7 20:21 编辑
47771885 发表于 2012-6-7 20:03
/ip firewall mangle
:put [get [find new-connection-mark=conn-1 ] comment]
?


是唯一,这个可以执行.得到正确的结果


:local x
:set x  [/ip firewall mangle get [find new-connection-mark=conn-1] comment]


现在可以执行...


真没搞懂什么原因...

routeros
回复

使用道具 举报

发表于 2012-6-8 05:32:55 | 显示全部楼层
  1. {
  2. :local x
  3. /ip firewall mangle
  4. :set x  [get [find new-connection-mark=conn-1 ] comment]
  5. :put $x
  6. }
复制代码
执行 目录问题 就如同 绝对目录和相对目录  你这个命令 一个绝对目录 没问题 一个相对目录 那就是/目录 呵呵肯定有问题 试试这个
routeros
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-1 05:12 , Processed in 0.064407 second(s), 4 queries , Gzip On, Redis On.

Powered by Discuz! X3.5 Licensed

© 2001-2023 Discuz! Team.

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