11-09-2011 08:53 AM
Hello,
I have tcl script that configures a specific class-map and i need to add to that class-map several access-list.
Right now i am trying to send all access-lists to one string and in the end execute ios_config command.
But it keeps me giving an error "Invalid input detected"
foreach alist $accesslist {
append cmd_acl "match access-group name $alist "
}
set result [ios_config "class-map classname" $cmd_acl]
Thanks
Solved! Go to Solution.
01-27-2012 02:14 AM
Did you ever find a solution for this ? I'm seeing the same problem here, and it's not caused by a long commandline, but rather the use of a list, rather than a literal series of strings,.
For example:
c3400me(tcl)#set d [list "class vlan1000" "service-policy 10mbps" ]
{class vlan1000} {service-policy 10mbps}
c3400me(tcl)#ios_config "policy-map TMP-POLICY-MAP" $d
^
% Invalid input detected at '^' marker.
but if I give ios_config the actual values in $d, it works.
c3400me(tcl)#ios_config "policy-map $TMP" "class vlan1000" "service-policy 10mbps"
c3400me(tcl)#show policy-map TMP_POLICY_MAP
Policy Map TMP_POLICY_MAP
Class vlan1000
service-policy 10mbps
Class class-default
service-policy 64kbps
So apparently ios_config doesn't like the data structure being passed to it.
I'm experienced in perl, but very new to tcl. Is there some way to typecast $d to force it to look the way that ios_config wants to see it ?
Also, is there some debugging or flag we can turn on that shows what command ios_config actually tried to execute when it got the error ?
11-09-2011 03:39 PM
Likely your command line is too long, and that is overflowing the parser. I would first suggest you print out your CLI command first to make sure it doesn't contain any errors, but if it is too long, try committing in steps:
set i 0
foreach alist $accesslist {
if { $i < 10 } {
append cmd_acl "match access-group name $alist "
incr i
} else {
set result [ios_config "class-map classname" $cmd_acl]
set i 0
}
}
if { $i < 10 } {
set result [ios_config "class-map classname" $cmd_acl]
}
01-27-2012 02:14 AM
Did you ever find a solution for this ? I'm seeing the same problem here, and it's not caused by a long commandline, but rather the use of a list, rather than a literal series of strings,.
For example:
c3400me(tcl)#set d [list "class vlan1000" "service-policy 10mbps" ]
{class vlan1000} {service-policy 10mbps}
c3400me(tcl)#ios_config "policy-map TMP-POLICY-MAP" $d
^
% Invalid input detected at '^' marker.
but if I give ios_config the actual values in $d, it works.
c3400me(tcl)#ios_config "policy-map $TMP" "class vlan1000" "service-policy 10mbps"
c3400me(tcl)#show policy-map TMP_POLICY_MAP
Policy Map TMP_POLICY_MAP
Class vlan1000
service-policy 10mbps
Class class-default
service-policy 64kbps
So apparently ios_config doesn't like the data structure being passed to it.
I'm experienced in perl, but very new to tcl. Is there some way to typecast $d to force it to look the way that ios_config wants to see it ?
Also, is there some debugging or flag we can turn on that shows what command ios_config actually tried to execute when it got the error ?
01-27-2012 05:04 AM
in my case i gave up of the solution of using lists.
I never really got to solve this problem... :|
01-27-2012 07:17 PM
One other thing to try is this:
foreach alist $accesslist {
append cmd_acl "match access-group name $alist "
}
eval "ios_config \"class-map classname\" $cmd_acl"
01-28-2012 06:24 PM
Hi,
I'm unsure why I was marked as a correct answer when all I did was say that I've got the same problem. I've also tried the suggestion from Joseph Clarke, to wrap it in an eval, but that made no difference.
In short, if I say
set a "policy-map tmp"
set b "class class-default"
set c "service-policy 64kbps"
ios_config $a $b $c
..then it works, but the following example does not work, and gives Invalid input detected
set a [list "policy-map tmp" "class class-default" "service-policy 64kbps"]
ios_config $a
and for completeness, this also fails with the same error
set a [list "policy-map tmp" "class class-default" "service-policy 64kbps"]
eval { ios_config $a }
01-28-2012 06:37 PM
You have to do the eval as I wrote it:
set a [list "policy-map tmp" "class class-default" "service-policy 64kbps"]
eval "ios_config $a"
I just tested this in a .tcl file, and it works.
01-28-2012 08:42 PM
Ah, thank you, I didn't spot that. Now tested and works.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide