Any idea how to generate binary output from Tclsh?
I've tried to port a simple Tcl full-screen editor to IOS and failed completely as IOS tclsh escapes control characters written by the puts command. For example, the following escape sequence should clear the screen, but as the ESCAPE character is displayed as ^[, it doesn't work:
router(tcl)#puts "\033\[2J"Any ideas how to persuade the router to display raw binary data?
^[[2J
router(tcl)#
SYNOPSIS
binary format formatString ?arg arg ...?
binary scan string formatString ?varName varName ...?
DESCRIPTION
This command provides facilities for manipulating binary data. The first form, binary format, creates a binary string from normal Tcl values. For example, given the values 16 and 22, on a 32 bit architecture, it might produce an 8-byte binary string consisting of two 4-byte integers, one for each of the numbers. The second form of the command, binary scan, does the opposite: it extracts data from a binary string and returns it as ordinary Tcl string values.
http://www.internetworkpro.org/wiki/Edit_files_using_TCL
@danshtr: Nice trick, which answers another question I've got a while ago. Thanks!
router(tcl)#set x [binary format ca* 27 "\[2J" ]
^[[2J
router(tcl)#puts "$x"
^[[2J
--
mtve
proc fahne { } {
exec "terminal international"
puts "\033\[2J"
puts "\033\[0;0H"
puts "\033\[0m |##########"
puts "\033\[0m |#########"
puts "\033\[0m |\033\[31m########"
puts "\033\[0m |\033\[31m########"
puts "\033\[0m |\033\[33m#########"
puts "\033\[0m |\033\[33m##########"
puts "\033\[0m |"
puts "\033\[0m |"
puts "\033\[0m |"
puts "\033\[0m\n\n\033\[32m Yepp \033\[0m"
}
fahne
proc processinput fd {} {
...
}
fileevent stdin readable {processinput stdin}
vwait forever
If you remove the shell code, all stty commands and the encoding parameter from the fconfigure commands it is at least startable on ios (with "term inter").