cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2252
Views
0
Helpful
7
Replies

tcl script problem

filipebatista
Level 1
Level 1

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

1 Accepted Solution

Accepted Solutions

ibatterbe
Level 1
Level 1

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 ?

View solution in original post

7 Replies 7

Joe Clarke
Cisco Employee
Cisco Employee

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]
}

ibatterbe
Level 1
Level 1

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 ?

in my case i gave up of the solution of using lists.

I never really got to solve this problem... :|

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"

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 }

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.

Ah, thank you, I didn't spot that. Now tested and works.