• securtcrt session配置转xshell的session配置


    参数:

    1.securtcrt的session目录

    2.一个xshell的模版文件

    3.输出目录(必须不存在,自动创建)

    #!/usr/bin/python
    # -*- coding:utf-8 -*-
    #转换secrt的session文件到xshell的session文件
    import os
    from sys import *
    
    def gen_xshell_session(path, tpl_file, out_session):
        os.mkdir(out_session)
        for f in os.listdir(path):
            print(f)
            fn = path + '/' + f
            if  os.path.isdir(fn):
                od = out_session + '/' + f
                gen_xshell_session(fn, tpl_file, od)
            else:
                if f.startswith('__'):
                    continue
                ext = f.find('.ini')
                ip = f[0:ext]
                xshell_cfg_file = out_session + '/' + ip + '.xsh'
                ifn = open(tpl_file, 'r')
                lns = ifn.readlines()
                ifn.close()
                tpl = os.path.basename(tpl_file)
                tpl_n = tpl.find('.xsh')
                tpl_ip = tpl[0:tpl_n]
                ofn = open(xshell_cfg_file, 'w')
                for ln in lns:
                    ln = ln.replace(tpl_ip, ip)
                    ofn.write(ln)
                ofn.close()
    
    
    
    
    
    
    if __name__ == '__main__':
        secrt_session = argv[1]
        xshell_xsh_tpl_file = argv[2]
        xshell_out_session_dir = argv[3]
    
        gen_xshell_session(secrt_session, xshell_xsh_tpl_file, xshell_out_session_dir)
    
     
  • 相关阅读:
    JavaScript 闭包(转)
    JavaScript 获取键盘扫描码
    前台网站优化方案
    设计模式之装饰者模式
    设计模式之蝇量模式
    设计模式之策略模式
    Algorithm学习之any_of
    Algorithm学习之all_of学习
    Algorithm学习之adjacent_find学习
    数据结构-表达式求值
  • 原文地址:https://www.cnblogs.com/moodlxs/p/3403828.html
Copyright © 2020-2023  润新知