#1
|
|||
|
|||
Time and Date Function
I am not sure if this is a possibility or not.
Is there a way to program a button to send a string that includes a current date and/or time command in any format that I choose. For example: I have several Adtran cabinets that cannot do domain-lookup so they are not able to look at an NTP server for their time reference. The time has to be set manually. So I would like to program a button that tells the terminal to go into configure termal, then clock set (current time in HH:MM:SS format) then hits enter instead of having to manually type it all in. Then also have something similar to setting the date as well. |
#2
|
|||
|
|||
Hi sussington,
What version of SecureCRT? On what OS/platform? Please list the explicit steps you would take to perform the action manually.
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#3
|
|||
|
|||
Brenda,
Thank you for responding. I am using version 8.7.3 of SecureCRT (I believe this is the latest) on a Windows 10 PC. The exact set of commands after logging into the terminal and enabling priviliage mode is as followed: conf t (carriage return) clock set <HH:MM:SS> <DD Mmm YYYY>(without the "<>")(carriage return) and that is it. HH is in 24 hour format. Here is an example of the full command: conf t clock set 15:47:26 16 Sep 2020 Last edited by sussington; 09-16-2020 at 02:56 PM. |
#4
|
|||
|
|||
Hi sussinsgton,
So are you saying when you press <ENTER> that it supplies current time and date? Or do you have to supply it? Assuming the former, just set the Function for the button to be Send String and then below is the string you would use. conf t\r clock set HH:MM:SS DD Mmm YYYY\r See also these two videos: - Button Bar Video https://www.youtube.com/watch?v=olyCcUWRimI - Button Bar Enhancements in SecureCRT https://youtu.be/qp82UWxGB8I
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#5
|
|||
|
|||
Brenda,
It is the latter of the two. I have to provide the the information for HH:MM:SS DD Mmm YYYY I was wonding if there is a way I can have SecureCRT gather that information automaically from the OS or and NTP (for example)and then I can set that information in a command format via a button. |
#6
|
|||
|
|||
Hi sussington,
That's the info I was looking for as well. At that point, you would probably need to run a script so you can add some logic to capture that info. ![]() I am not familiar with Adtran devices. Is there a Date() or Now() function provided by the shell? Would you connect with trace options output (enabled from the File menu) and then post the line (about 5-10 lines from top) that includes the Remote Identifier?
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#7
|
|||
|
|||
Quote:
setclock.py Code:
# $language = "Python" # $interface = "1.0" from datetime import datetime def Main(): CRT = crt Screen = CRT.Screen Screen.Send("config term\r") Now = datetime.now() Formatted = Now.strftime("%H:%M:%S %d %b %Y") Screen.Send("clock set " + Formatted + "\r") Main() Code:
MDS9710# config term Enter configuration commands, one per line. End with CNTL/Z. MDS9710(config)# clock set 19:55:37 16 Sep 2020 Wed Sep 16 19:55:37 EDT 2020 MDS9710(config)# |
#8
|
|||
|
|||
Hello,
Thanks kdmorse! Sussington, Are you able to incorporate kdmorse's suggestions and then map a button on the button bar to run the script?
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#9
|
|||
|
|||
Thanks kdmorse and bgagnon I really appreciate the replys. I'm not to family as to how scripting works and will need to do some research how to go about adding this in and how it works.
|
#10
|
|||
|
|||
Hi sussington,
The only thing different is what you said your initial command sent needs to be. So it would look something like below. Note that you need to put in whatever your shell prompt is where noted: Code:
# $language = "Python" # $interface = "1.0" from datetime import datetime def Main(): CRT = crt Screen = CRT.Screen Screen.Synchronous = True Screen.Send("config t\r") Screen.WaitForString("your_shell_prompt") Now = datetime.now() Formatted = Now.strftime("%H:%M:%S %d %b %Y") Screen.Send("clock set " + Formatted + "\r") Main()
__________________
Thanks, --Brenda VanDyke Software Technical Support support@vandyke.com (505) 332-5730 |
#11
|
|||
|
|||
Quote:
Create an empty file named setclock.py, and paste one of the scripts into it, and save it somewhere on your hard disk. (make sure it's named setclock.py, not setclock.py,txt). Then as a test, on the menu hit Script -> Run Script, navigate to your script, and hit run. If it suits your needs, you can then add a button, or command manager line, (or even keybind) that maps to Run Script -> yourscript name. |
![]() |
Thread Tools | |
Display Modes | |
|
|