Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. And see here for current known issues.

New Member

TCL in IOS - how to insert a carriage return

Greetings,

I have a very simple TCL script which clears the lines on a terminal server:

puts [open "flash:clear2" w+] {
puts "Clearing line 33"
puts [exec "clear line 33"]
puts "Clearing line 34"
puts [exec "clear line 34"]
.
.   (etc.)
.
puts "Clearing line 46"
puts [exec "clear line 46"]
}

It works fine except that I have to press enter for each line.  The router's responds to the "clear line" command with a " [confirm] " and waits for the enter key to be hit.  I'd like to automate this and was looking for a way to respond to the " [confirm] " within the script.  I thought maybe a "catch" would work but can't seem to find a link that explains how to accomplish this.  Anyone know how to do this?

Thanks in advance!

George

Everyone's tags (2)
5 REPLIES
Blue

Re: TCL in IOS - how to insert a carriage return

typeahead "y" (or "\r"); "typeahead" reportedly only started working correctly since 12.4(15)T.

See this for reference:

http://wiki.nil.com/Insert_responses_to_command_prompts_in_Tclsh

New Member

Re: TCL in IOS - how to insert a carriage return

No, that doesn't seem to do it although now I see the "[confirm] " and "[OK]" after I hit the enter key.  I tried adding a second typeahead as well but no luck.  Thanks all the same though.

George

Cisco Employee

Re: TCL in IOS - how to insert a carriage return

You want:

typeahead "y" ; exec "clear line 37"

Cisco Employee

I hacked a way to make

I hacked a way to make carriage return in tclsh work. You will need the following two lines after your command line needing a carriage return (and sometimes a set before the command as well):

r

typeahead "\r"

 

So, for instance, to do a repeated tclsh copy tftp command that requires CR, I use in tclsh script:

...

r

typeahead "\r"

copy tftp://192.168.1.1/largefile flash:largefile

r

typeahead "\r"

...

 

This works fine even in a loop.

The line with r will causes "No open connections" message on CLI of no known consequences. The typeahead text is saved in the buffer and entered as user-typed input on the command line after the tclsh script command completes.

Arif

New Member

I googled the carriage return

I googled the carriage return issue, and we're trying to do the same thing.

This is working for me, on a  3725 with 12.4(25):

tclsh
for {set i 33} {$i < 49} {incr i} {
      typeahead "\r";clear line $i}
tclquit

4101
Views
0
Helpful
5
Replies
CreatePlease login to create content