命令行自动打开多个命令窗口,并进入到指定的目录中,或者自动登录多台

19 篇文章 0 订阅
2 篇文章 0 订阅
1.每次开机需要打卡多个命令窗口,登录到不同的服务器
 
可以使用一下方式,前提是 必须安装 guake,python
 
1.编写 python
 
 
#!/usr/bin/env python
import os
#pcList=['47','48','49','60','61','94']
#pcList=['151','152','153','154', '155','156']
pcList=['18','19','31']
for i in pcList:
  os.system("guake -n 1")
  os.system("guake -r %s"%i)
  os.system("guake -e 'ssh  root@172.16.236.%s'"%i)
 
 
将以上内容保存在 文件  startAll 中 ,给 startAll  提供可执行权限
sudo chmod +x startAll 
 
2.启动 guake  (将guake设置为开机启动)
3..在guake 的命令窗口中  执行  startAll   (这里需要将确定登录目标机器不需要输密码,具体操作:参考 ssh  自动登录)
 
 
连接到远程服务器: 
 
 1 #!/usr/bin/env python
  2 import os
  3 #pcList=['47','48','49','60','61','94']
  4 #pcList=['151','152','153','154', '155','156']
  5 pcList=['151','152','153','154','155','156']
  6 for i in pcList:
  7   os.system("guake -n 1")
  8   os.system("guake -r %s"%i)
  9   os.system("guake -e 'ssh root @172.16.205.%s'"%i)
 
 
连接到远程服务器并且进入到指定目录:

 
 
1 #!/usr/bin/env python
  2 import os
  3 #pcList=['47','48','49','60','61','94']
  4 #pcList=['151','152','153','154', '155','156']
  5 pcList=['151','152','153','154','155','156']
  6 for i in pcList:
  7   os.system("guake -n 1")
  8   os.system("guake -r %s"%i)
  9   os.system("guake -e 'ssh root@172.16.205.%s'"%i)
 10   os.system("guake -e cdpkg")
 
 
 
 
进入到本地目录:
1 #!/usr/bin/env python
  2 import os
  3 options=[
  4 'parser',
  5 'sender',
  6 'control',
  7 'tracer'
  8 ]
  9 for i in options:
 10   os.system("guake -n 1")
 11   os.system("guake -r %s"%i)
 12   os.system("guake -e %s"%i)
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值