cancel
Showing results for 
Search instead for 
Did you mean: 

Get current date

Get current date

EtherNation_Use
Contributor II
Create Date: Jul 19 2012 9:20AM

Hi guys,

how can i get the current date from CLI ou upm profile?
i saw on concepts guide this script, but dont work for me:

set var CLI.OUT " "
show switch
set var date $TCL(lrange ${CLI.OUT} 27 29)
set var year $TCL(lrange ${CLI.OUT} 31 31)
set var date $TCL(linsert $date 3 $year)
set var time $TCL(lrange ${CLI.OUT} 30 30)
show var date
show var time


"set var date $TCL(lrange ${CLI.OUT} 27 29)
^
%% Invalid input detected at '^' marker."

Explain:
I wanna make an auto backup, connecting to a remote machine throw tftp, i can do it, but i want my .cfg file named with the current date.

by the way i have sntp client configured.

Tks,

Luiz Maia

(from Luiz Claudio_Maia)
1 REPLY 1

EtherNation_Use
Contributor II
Create Date: Jul 20 2012 12:05AM

Hi!

This is how I do it in my backup script:

set var baseSystemTime $TCL(clock seconds)
set var systemTime $TCL(clock format $baseSystemTime -format {%H%M})
set var year $tcl(clock format $baseSystemTime -format {%Y})
set var month $tcl(clock format $baseSystemTime -format {%m})
set var day $tcl(clock format $baseSystemTime -format {%d})

set var cli.out 0
show switch
set var hostname $tcl(lindex ${cli.out} 1)

set var filename $(hostname)_$(year)-$(month)-$(day)_$(systemTime).cfg


I hope this can be of use to you.

Best regards,
Daniel
(from Daniel_Warhammar)
GTM-P2G8KFN