Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements
Webcast-Catalyst9k
New Member

tcl script problem

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

Everyone's tags (2)
1 ACCEPTED SOLUTION

Accepted Solutions
New Member

tcl script problem

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 ?

7 REPLIES
Cisco Employee

Re: tcl script problem

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

tcl script problem

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 ?

New Member

Re: tcl script problem

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

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

Cisco Employee

Re: tcl script 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"

New Member

tcl script problem

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 }

Cisco Employee

tcl script problem

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.

New Member

tcl script problem

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

1114
Views
0
Helpful
7
Replies
CreatePlease to create content