cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
828
Views
0
Helpful
2
Replies

TCL with date env error

Marwan Urabi
Beginner
Beginner

Hi,

 

I'm trying to make TCL scrip to copy running config to tftp server but when I use date env I get error.

 

when I copy this text to tcl I get file is created but without any data

-------------------------------------------------------------------------

tclsh
    set x [ open "flash:backmeupnow.tcl" w+]
    set time [clock format [clock seconds] -format "%H%M%S"]
    set ken { write mem
    show run | redirect tftp://10.0.3.122/Routers_Config/S05-RW877W-.$time._v1.txt
   }
   puts $x $time $ken
   close $x
tclquit

---------------------------------------------------------------------------------

if I remove the $time from puts It's create the file but when I run the TCL I get error

 

can't read "time": no such variable
    while executing
"show run | redirect tftp://10.0.3.122/Routers_Config/S05-RW877W-.$time._v1.txt "
    (file "backmeupnow.tcl" line 2)

 

Regards

Marwan Urabi

 

 

 

 

2 Replies 2

Flavio Miranda
Advisor
Advisor

Hi

 This format always worked for me:

 

set systemTime [clock seconds]

set timestemp "[clock format $systemTime -format  %Y-%m-%d_%H%M]" 

set nomearc "file-name"

log_file  "${nomearc}${timestemp}.txt"

 

 

-If I helped you somehow, please, rate it as useful.-

Hi

I'm testing to update as your reply but it's still same error
Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Recognize Your Peers