首页 > 系统相关 >批量创建xshell会话

批量创建xshell会话

时间:2022-11-15 21:03:02浏览次数:32  
标签:f2 file 批量 ip 192.168 会话 context xshell xsh

import re
import os

tmp_file = r"C:\Users\yc\Documents\NetSarang Computer\7\Xshell\Sessions\192.168.2.253.xsh"


with open (tmp_file , "r+", encoding="utf-16-le") as file:
    context = file.read()
    print(context)


list1 = [
    '192.168.1.1',
    '192.168.2.2',  # 可以在下一行插入ip,格式: 'ip',
    '192.168.3.3'
    ]

for ip in list1:
    context = re.sub("Host=.*", "Host=" + ip, context)
    new_file = ip + ".xsh"
    with open(r"C:\Users\yc\Documents\NetSarang Computer\7\Xshell\Sessions\ " + new_file, 'w+', encoding='utf-8', errors='ignore') as f2:
        f2.write(context)
        f2.close()
        print("生成文件" + ip + ".xsh")

  

标签:f2,file,批量,ip,192.168,会话,context,xshell,xsh
From: https://www.cnblogs.com/yc-tec/p/16893885.html

相关文章

  • 根据继承接口批量注入GRPC客户端
    ///<summary>///作用域批量注入grpc数据///</summary>///<typeparamname="IGrpcDependency">根据泛型获取需要注入的grpc接口<......
  • Linux——虚拟机如何连接XShell
    目录一、检查虚拟机设置的网络连接是否为NAT模式二、虚拟网络编辑器中查看IP地址三、设置虚拟机的IP地址,子网掩码,网关,DNS四、XSell中连接虚拟机五、总结一、检查虚拟......
  • netmiko批量操作华为设备
    importnetmikoimportopenpyxlfromnetmikoimportConnectHandlerfromopenpyxlimportload_workbookfromconcurrent.futuresimportThreadPoolExecutor#从ex......
  • 会话保持 Session和cookie
      Session是什么?      Session在网络中称为会话控制,是服务器为了保护用户状态而创建的一个特殊的对象,简而言之,session就是一个对象,用于存储信息。 Sess......
  • mongodb增删改查 及批量操作(二)
    1.增加insert插入多笔数据db.stu.insert([{_id:3,sn:'003',name:'zhangfei'},{_id:4,sn:'004',name:'guanyu'},{sn:'005',name:'liubei'}])增加复杂的文档db.stu.insert({na......
  • nuxt3批量引入svg文件
    nuxt3引入svg的方法和viet的差不多,只是细节上有些不同同样是两步,引入svg组件和引入svg文件第一步:引入svg组件在components文件夹下创建SvgIcon.vue组件<template>......
  • 批量转换MP3
    find.-name"*mp4"|grepmp4>.0001whilereadlinedoecho"$line"":copying-----"Vpath_name="$line"cp-rp"$line".done<.0001ls|grepm......
  • SqlBulkCopy(批量复制)方法,高性能批量插入数据
    https://blog.51cto.com/u_15162069/2751372https://blog.csdn.net/five_s/article/details/115213102SQLServer批量插入数据方案SqlBulkCopy相较于Insert语句而言......
  • chrome浏览器 开发者工具F12中某网站的sources下的源码如何批量保存
    1.常用保存Sources源码的两种方法1.1单个文件直接右键另存为1.2单个页面保存网页,就会把引用到的所有文件下载下来如果页面很多,文件也很多,静态资源也很多,那么得一......
  • 28、批量实现txt文件内容合并
    题目:  在many_org文件夹中有三个.txt文件,如何将三个文件的内容整理到一个文件里?思路:  1、遍历路径下的所有文件。  2、判断出.txt文件,将其所有内容保存至新列表......