惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

云风的 BLOG
云风的 BLOG
The GitHub Blog
The GitHub Blog
Y
Y Combinator Blog
博客园 - 三生石上(FineUI控件)
T
The Blog of Author Tim Ferriss
宝玉的分享
宝玉的分享
Hugging Face - Blog
Hugging Face - Blog
WordPress大学
WordPress大学
V
Visual Studio Blog
小众软件
小众软件
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
MongoDB | Blog
MongoDB | Blog
V
V2EX
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 【当耐特】
Microsoft Azure Blog
Microsoft Azure Blog
The Cloudflare Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Engineering at Meta
Engineering at Meta
L
LangChain Blog
Martin Fowler
Martin Fowler
GbyAI
GbyAI
博客园 - 司徒正美

lvbibir's Blog

shell | 磁盘空间分析脚本 Linux cat 和 tee 命令写入文件 python | 使用 uv 管理你的 python 环境 Claude Code 完整配置指南 windows | mihomo 内核独立部署指南 linux | 磁盘扩容 wsl | 释放长久运行占用的磁盘空间 mysql | 线程上限问题处理 麒麟 7.6 安装谷歌 OTP 认证模块 suse 12sp5 升级 openssh 及 openssl suse 12sp5 部署 mysql 5.7 《谁的青春不迷茫》 docker | centos7 部署 docker vim | 基础配置和使用 windows | rime 输入法 & 雾凇方案 wsl | 原生 linux 方式安装 docker nodejs | fnm + pnpm 开发环境配置 wsl | 安装配置 miniconda 虚拟环境 wsl | 自动更新系统代理 wsl | bashrc 环境变量不正确加载的处理方法 wsl | win10 安装 wsl2 troubleshooting | ssh 成功但是 scp 失败 linux | 常用命令总结 docker 部署 piclist shell | 检测网站存活并自动钉钉告警 Zabbix | 监控端口连通性并自动追踪 TCP 路由 windows | 自定义开机快速启动项 windows | miniconda 配置 python 虚拟环境 Zabbix | 监控主机到指定 ip 的流量大小 shell | centos 初始化
shell | sshpass 批量传输文件及执行命令
lvbibir · 2024-02-01 · via lvbibir's Blog
#!/bin/bash

username="root"
password="123123"
port="22"

# 判断ip检查文件是否存在
if [ ! -f "./ip_check.txt" ]; then
  # 清空检查文件
  /usr/bin/true >./ip_check.txt
else
  # 创建检查文件
  /usr/bin/touch ./ip_check.txt
fi

# 传输文件
execut_ftp_file() {
  IFS=$'\n'
  for file in $(cat ./ftp_file.conf); do
    /opt/sshpass/bin/sshpass -p $password scp -o StrictHostKeyChecking=no ./$file $username@$1:/opt/
    echo "$1 ---- $file 文件传输完成"
  done
}

execut_commad_file() {
  IFS=$'\n'
  for com in $(cat ./execut_commad.conf); do
    /opt/sshpass/bin/sshpass -p $password ssh -o StrictHostKeyChecking=no $username@$1 $com
    echo "$1 ---------- $com 命令执行完成"
    sleep 3
  done
}

for line in $(cat ./ip.txt); do
  Ture_ip=$(/usr/bin/ping -c 2 $line)
  if [ $? != "0" ]; then
    echo "$line is blocked" >>./ip_check.txt
  else
    execut_ftp_file $line
    sleep 2
    execut_commad_file $line
  fi

done