资源简介
Securecrt64.7z
代码片段和文件信息
# $language = “python“
# $interface = “1.0“
# AddCommentToLogFile.py
#
# Description:
# This example script allows you to add a custom line of text to your
# SecureCRT log file. The user will be prompted for the text to add
# to the log file; logging will be stopped; the text provided by the
# user will be appended to the log file; then SecureCRT logging will
# be restarted.
#
# This method only works with connections associated with a Session
# configuration in which a log file is specified.
#
# Demonstrates:
# - How to prompt for user input using the SecureCRT InputBox() function.
# - How to access Session.LogFileName to determine the log file name
# stored for the current session.
# - How to use the Session.Logging property to determine if logging
# is currently active.
# - How to use the Python replace() method to substitute substrings
# within an existing string.
# - How to use the Python file object to open an existing text file
# and append data.
#
import datetime
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def Main():
# Make this script tab safe
tab = crt.GetscriptTab()
if tab.Session.LogFileName == ““ :
crt.Dialog.MessageBox(“Error.\n\n\
This script requires a session configuration in which a \
log file is defined.\n\n\
Specify a Log file name in Session Options ““Terminal / \
Log File““ and run this script again.“)
return
# 1. Stop logging to free up the log file for writing by our script.
tab.Session.Log(False)
# 2. Prompt the user for the text to add to the log file.
now = str(datetime.datetime.now())
textToAdd = crt.Dialog.Prompt(
“Add comment to log file (use \\r\\n to separate multiple lines):\n\n\
Comment will be prefaced with current timestamp:\n“ + now + “\n“
“Add Comment To SecureCRT Log File\n“ + now + “: “)
# Prompt returns ““ if the user cancels
if textToAdd == ““:
return
# 3. Write data to the file. If you want to include a newline you must
# concatenate a \n character to the end of the line. Note also that you can
# wrap the comment with certain markers and not require the user to enter
# these markers when prompted. Although the prompt function only allows
# one line per entry you can set up a tag that can be used to represent
# a new line such as “\r\n“ and then replace this tag with a \n as we
# have done in this example:
textToAdd = “\n/********************************************/ \n\
* “ + now + “: \n* “ + textToAdd.replace(“\r\n“ “\n* “) + “\n\
/********************************************/ \n“
WriteToFile(tab.Session.LogFileName textToAdd)
# 4. Start up logging again making sure we append rather than overwrite.
tab.Session.Log(True True)
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
def WriteToFile(filename data):
# filename: Full path to file
# data: data to be written to the
相关资源
- Eric61703中文汉化版.zip
- 矩阵分析与应用课件_张贤达_清华课件
- 百度云(1).zip
- 王红梅.rar
- 周志华机器学习.zip
- 榆落微时光1.0.39小程序前端.zip
- 智慧答题-崛企5.1.2.zip
- 信号检测与估计理论清华大学版本.
- 计算机组成原理(第2版)-唐朔飞.p
- qq_28971045_10491491.zip
- 图论及其应用课后答案[1-12章].pdf
- 微擎商业版框架2.0.4去授权一键安装源
- zhajinhuaTutorial-master.zip
- wapj.zip
- 5CBBAE958673ABD2DF1E04E7F11794DC.pdf
- SimpleMall.zip
- 康熙字典数据库.rar
- Test2.zip
- FruitShopping.rar
- 迅雷7.2.8.3572去广告优化版VIP6+高速通
- 40-A5-EF-3E-90-AA.bin
- 软件工程.rar
- 给产品经理讲技术-打印版.pdf
- ahakme.zip
- 男神女神投票3.7.3投票工具2.3.5投票排
- 超人名片v1.5.6名片小程序的首选.zip
- 微擎商业版框架v1.8.2.3去授权一键安装
- 微擎步数宝4.2.0前后端开源版.zip
- z5gtif.zip
- qwt-6.1.0最新官方.rar
评论
共有 条评论