不可使用xshell,xftp等工具,当然我也不用,常用mobaxsterm,比较直观看到服务器性能以及拖拽文件方便,再次不做赘述。此时同时同事们面临多个xshell得session导入费时问题,参与研究,找到解决方法。参考于 https://www.cnblogs.com/hanxiaomeng/p/15066986.html
Python官网:https://www.python.org/ 安装最新python脚本并选择add path
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# xshell session to mobaxterm session file
# Support: TELNET, serial, SSH
# Usage: xshell2mobaxterm.py Xshell_Session_Direcotry
# Example: python3 xshell2mobaxterm.py D:\Xshell\Session >mobaxterm.mxtsessions
# Linux platform enviroment: LANG=zh_CN.utf8/en_US.utf8
# Windows: python3.6 cmd run it.
import os, sys
def convert_x2m(xshell_session_file, num):
#print(xshell_session_file)
ssh_format = (
'[{BookMarks}]\n'
'SubRep={Directory}\n'
'ImgNum=42\n'
'{SessionName} ({UserName})=#109#0%{Host}%{Port}%{UserName}%%-1%-1%%%{Port}%%0%0%0%%%-1%0%0%0%%1080%%0%0%1#MobaFont%10%0%0%0%15%236,236,236%30,30,30%180,180,192%0%-1%0%%xterm%-1%-1%_Std_Colors_0_%80%24%0%1%-1%<none>%%0#0# #-1\n'
)
telnet_format = (
'[{BookMarks}]\n'
'SubRep={Directory}\n'
'ImgNum=41\n'
'{SessionName} ()= #98#1%{Host}%{Port}%%%2%%%%%0%0%%1080%#DejaVu Sans Mono%{FontSize}%0%0%-1%15%236,236,236%30,30,30%180,180,192%0%-1%0%%xterm%-1%-1%_Std_Colors_0_%80%24%0%1%-1%<none>%%0%1%-1#0# #-1\n'
)
serial_format = (
'[{BookMarks}]\n'
'SubRep={Directory}\n'
'ImgNum=42\n'
'{SessionName}= #131#8%-2%100{Speed}%3%0%0%1%2%{Port}#DejaVu Sans Mono%{FontSize}%0%0%-1%15%236,236,236%30,30,30%180,180,192%0%-1%0%%xterm%-1%-1%_Std_Colors_0_%80%24%0%1%-1%<none>%%0%1%-1#0# #-1\n'
)
session_file = open(xshell_session_file, 'r')
session_lines = session_file.readlines()
xshell_attr = {
'num': num}
xshell_attr['Directory'] = os.path.dirname(xshell_session_file.replace(sys.argv[1], '').strip('\\'))
xshell_attr['SessionName'] = os.path.basename(xshell_session_file).rsplit('.',1)[0]
if num == 0:
xshell_attr['BookMarks'] = 'Bookmarks'
else:
xshell_attr['BookMarks'] = 'Bookmarks_{num}'.format(num=num)
for line in session_lines:
if line.startswith('UserName='):
xshell_attr['UserName'] = line.split('=')[1].strip('\n')
elif line.startswith('Port='):
xshell_attr['Port'] = line.split('=')[1].strip('\n')
elif line.startswith('FontSize='):
xshell_attr['FontSize'] = line.split('=')[1].strip('\n')
elif line.startswith('Host='):
xshell_attr['Host'] = line.split('=')[1].strip('\n')
elif line.startswith('Protocol='):
xshell_attr['Protocol'] = line.split('=')[1].strip('\n')
elif line.startswith('BaudRate='):
xshell_attr['Speed'] = line.split('=')[1].strip('\n')
#print(xshell_attr)
x = 1
if xshell_attr.get('Protocol')is not None and xshell_attr.get('Protocol').lower().startswith('ssh'):
x = ssh_format.format(
Directory = xshell_attr.get('Directory') or '',
SessionName = xshell_attr.get('SessionName') or 'default',
UserName = xshell_attr.get('UserName') or '',
Port = xshell_attr.get('Port') or '22',
FontSize = xshell_attr.get('FontSize') or '12',
num=xshell_attr['num'],
Host=xshell_attr.get('Host') or '',
BookMarks=xshell_attr['BookMarks']
)
elif xshell_attr.get('Protocol')is not None and xshell_attr.get('Protocol').lower() == 'telnet':
x = telnet_format.format(
Directory = xshell_attr.get('Directory') or '',
SessionName = xshell_attr.get('SessionName') or 'default',
UserName = xshell_attr.get('UserName') or '',
FontSize = xshell_attr.get('FontSize') or '12',
Port = xshell_attr.get('Port') or '23',
num=xshell_attr['num'],
Host=xshell_attr.get('Host') or '',
BookMarks=xshell_attr['BookMarks']
)
elif xshell_attr.get('Protocol') is not None and xshell_attr.get('Protocol').lower() == 'serial':
x = serial_format.format(
Directory = xshell_attr.get('Directory') or '',
SessionName = xshell_attr.get('SessionName') or 'default',
FontSize = xshell_attr.get('FontSize') or '12',
Port = xshell_attr.get('Port') or '',
Speed = xshell_attr.get('Speed') or '9600',
num = xshell_attr['num'],
BookMarks = xshell_attr['BookMarks']
)
#print(x.replace('/', '\\'))
if x==1:
return None
else:
return x.replace('/', '\\')
def generate_mobaxterm_sessions(xshell_session_path, count):
#print(session_path)
base_dir = os.listdir(xshell_session_path)
for file in base_dir:
file = os.path.join(xshell_session_path, file)
try:
os.listdir(file)
#print(file)
generate_mobaxterm_sessions(file, count)
except:
if not file.endswith('.xsh'): continue
if convert_x2m(file, count[0]) is None: continue
print(convert_x2m(file, count[0]))
count[0] += 1
if __name__ == '__main__':
count = [0]
generate_mobaxterm_sessions(sys.argv[1], count)
**
**
文章浏览阅读306次。1. eclipse配置lombok 拷贝lombok.jar到eclipse.ini同级文件夹下,编辑eclipse.ini文件,添加: -javaagent:lombok.jar2. myeclipse配置lombok myeclipse像eclipse配置后,定义对象后,直接访问方法,可能会出现飘红的报错。 如果出现报错,可按照以下方式解决。 ..._eclispe每次运行个新项目都需要重新配置lombok吗
文章浏览阅读1.2w次,点赞31次,收藏126次。#注意:笔者在2021/11/11当天调试过这个代码是可用的,由于pdfminer版本的更新,网络上大多数的语法没有更新,我也是找了好久的文章才修正了我的代码,仅供学习参考。1、把pdf文件移动到本代码文件的同一个目录下,笔者是在pycharm里面运行的项目,下图中的x1文件夹存储了我需要转换成文本文件的所有pdf文件。然后要在此目录下创建一个存放转换后的txt文件的文件夹,如图中的txt文件夹。2、编写代码 (1)导入所需库# coding:utf-8import ..._python批量读取文字并批量保存
文章浏览阅读646次。内存的分配方式、常见的内存错误即对策、指针与数组的对比、free、杜绝“野指针“、内存耗尽怎么办、malloc/free 的使用要点_函数造成的内存错误怎么解决
文章浏览阅读4.2k次。一. 多维数组的概念1. 一维像线,array[0],索引2. 二维像表格(面),array[0][0],行列3. 三维像立方体,array[0][0][0],行列厚度二. 三维数组在虚拟漫游中的应用使用三维数组表示一栋楼的数据设定结构体 RoomInfo属性 变量名称 数据类型面积 RoomAreaF 单价 Price_ue 二维数组
文章浏览阅读2.5k次,点赞2次,收藏2次。bug1:UnicodeDecodeError: ‘gbk’ codec can’t decode byte 0xb1 in position 5: illegal multibyte sequence解决办法1:上面报错的意思就是,默认以gbk的方式读取数据,但是文本数据是utf-8类型的,这是需要用到另一个参数encoding,也就是把它编码成与文本一样类型的格式,下面的代码encoding="utf-8"就是要修改的地方,如果不写编码格式,默认是encoding="gbk"的#open(“.__csv.error: line contains nul
文章浏览阅读204次。创作者:芝麻侃教育众所周知,河南省是当之无愧的高考大省:考生超过了百万,高校超过了百所。然而遗憾的是,除了一流大学建设高校郑州大学和一流学科建设高校河南大学之外,河南省没有几所可以“拿得出手”的重点院校。不过俗话说得好:“知耻而后勇”。虽然河南省属院校的整体实力并不是很强,但是发展速度很快:郑州大学和河南大学双双入围双一流,河南科技大学、河南理工大学、河南师范大学以及河南农业大学等九所院校获重点支..._黄淮学院和安阳工学院电子科哪个好
文章浏览阅读715次,点赞30次,收藏22次。Flume基础架构、安装部署、入门案例、断点续传源码修改
文章浏览阅读1.3k次。每日一问:介绍一下你经常浏览的 Android 技术网站_android 英文技术网站
文章浏览阅读826次。本文介绍的是CVPR 2020的论文《Fine-grained Video-Text Retrieval with Hierarchical Graph Reasoning》(已开源),文章作者是中国人民大学博士生陈师哲同学,这项工作是陈师哲同学在澳大利亚阿德莱德大学吴琦老师组访问时所完成。作者|陈师哲编辑 | 贾 伟论文链接:http://arxiv.org/abs/2003...._细粒度跨模态检索
文章浏览阅读9.3k次,点赞8次,收藏39次。知识点:第一个app,显示Helloworld一、创建一个空项目创建项目启动 Visual Studio。单击“文件”>“新建”>“项目”以创建新项目 。在“新建项目” 对话框中,单击“Android 应用” 模板。将新项目命名为Hello(Phoneword是微软示例,本人太懒,不改了),然后单击“确定” : 在“新 Android 应用” 对话框中,依次单击“BlankA..._c#开发app
文章浏览阅读267次,点赞5次,收藏9次。探索Camera2Demo:一款深入理解Android Camera2 API的开源示例项目项目地址:https://gitcode.com/wangshengyang1996/Camera2Demo项目简介Camera2Demo 是一个由wangshengyang1996开发并维护的Android应用示例,旨在帮助开发者更好地理解和使用Android的Camera2 API。该项目通过提供..._android camera2 demo
文章浏览阅读121次。2019独角兽企业重金招聘Python工程师标准>>> ...