Example:
Host% cat my_append
#!/usr/bin/env expect
set my_first {#Cisco Tcl Signature V1.0}
set newline {}
set my_file [lindex $argv 0]
set my_new_file ${my_file}_sig
set my_new_handle [open $my_new_file w]
set my_handle [open $my_file r]
puts $my_new_handle $newline
puts $my_new_handle $my_first
foreach line [split [read $my_handle] "\n"] {
set new_line {#}
append new_line $line
puts $my_new_handle $new_line
}
close $my_new_handle
close $my_handle
Step 3
Run the script, supplying the name of the file containing the nonbinary signature file (nonbinary-signature-file) as the
input argument.
In this example, the my_append script is run with the nonbinary signature file hello.hex specified as input. The output
file will be named hello.hex_sig.
Example:
Host% my_append hello.hex
Step 4
ls -l
This command displays detailed information about each file in the current directory, including the permissions, owners,
size, and when last modified.
Example:
Host% ls -l
total 80
-rw-r--r-- 1 janedoe eng12 1659 Jun 13 10:18 cert.pem
-rw-r--r-- 1 janedoe eng12 115 Jun 13 10:17 hello
-rw-r--r-- 1 janedoe eng12 3815 Jun 13 10:20 hello.hex
-rw-r--r-- 1 janedoe eng12 3907 Jun 13 10:22 hello.hex_sig
-rw-r--r-- 1 janedoe eng12 1876 Jun 13 10:16 hello.pk7
-rwxr--r-- 1 janedoe eng12 444 Jun 13 10:22 my_append
-rw-r--r-- 1 janedoe eng12 1679 Jun 12 14:55 privkey.pem
-rw-r--r-- 1 janedoe eng12 451 Jun 12 14:57 pubkey.pem
The hello.hex file contains nonbinary data (stored as a hexadecimal dump) converted from the binary signature in the
signed Tcl file hello.pk7. The my_append file contains the script that inserts a comment character at the beginning of
each line of the input file. The hello.hex_sig file is the file created by running the my_append script on the nonbinary
signature file.
Step 5
cat signed-tcl-file commented-nonbinary-signature-file > signed-tcl-script
This command appends the contents of the nonbinary signature file (commented-nonbinary-signature-file) to the signed
Tcl file stored in DER PKCS#7 format (in the signed-tcl-file file). The concatenated output is written to the file
signed-tcl-script.
Consolidated Platform Configuration Guide, Cisco IOS Release 15.2(4)E (Catalyst 2960-X Switches)
1833
How to Configure Signed Tcl Scripts