VanDyke Software Forums

VanDyke Software Forums (https://forums.vandyke.com/index.php)
-   General (https://forums.vandyke.com/forumdisplay.php?f=11)
-   -   Keymap adding variables to Send String (https://forums.vandyke.com/showthread.php?t=13352)

ZekeB 01-09-2019 12:04 PM

Keymap adding variables to Send String
 
Here's my use case: I'm doing a tail -f on a file and I have a mapping to send a string that hits return several times, draws a line of dashes, then a few more returns.

That works fine. What I'd really like is the ability to insert variables into the string such as the current time as I've mocked up below.


\n\n\n\n\n------------------{HH:MM:SS}---------------------------------\n\n\n

Is there a way to do this? The session is in tail, so doing a date +%H:%M:%S or something similar that would have to be processed on the server won't help.

ZekeB 01-09-2019 12:11 PM

Answering my own question with a HORRIBLY ugly hack that I would be embarrassed to use. ;)

\n\n\n\n\032date\nfg %-\n\n\n\n

berdmann 01-09-2019 01:43 PM

Hi ZekeB,

There aren't any substitutions for date/time available in SecureCRT for plain mapped keys SEND STRING operations.

I have added a feature request on your behalf to add this functionality in SecureCRT.

If this functionality becomes available in a future version, we will be sure to let you know. If you would like to be notified directly please send an email to Support@VanDyke.com with "Feature Request Forum Post 13352" in the subject line.

In the mean time, you can get the behavior you desire by mapping your key combo to run a script instead of using the SEND_STRING function. For example:

Code:

# $language = "Python"
# $interface = "1.0"

import datetime
g_strDateTimeTag = datetime.datetime.now().strftime("%H:%M:%S")

strLeaderDash = "-" * 30
crt.Screen.Send("\r\n\r\n\r\n{0}{1}{2}{3}{4}\r\n\r\n\r\n".format(strLeaderDash, "{", g_strDateTimeTag, "}", strLeaderDash), True)


ZekeB 01-10-2019 10:57 AM

Cool! Thank you very much, Brittney!


All times are GMT -6. The time now is 12:12 PM.