行业知识
expect自动化交互案例——sftp自动上传log到主机指定位置
2026-11-12 13:54:52
来源:互联网转载
脚本作用
从主���上拉取数据生成log文件,再通过expect自动化交互通过sftp上传log文件到指定位置
()#!/bin/bashcur_date="`date +%Y-%m-%d`"#收取计算机信息echo "1.1计算机名称" >> /tmp/$(hostname)_quarterly_check_$cur_date_$cur_date.loghostname >> /tmp/$(hostname)_quarterly_check_$cur_date.logecho "=========================================================================" >> /tmp/$(hostname)_quarterly_check_$cur_date.logecho "1.2操作系统版本" >> /tmp/$(hostname)_quarterly_check_$cur_date_$cur_date.logcat /etc/redhat-release >> /tmp/$(hostname)_quarterly_check_$cur_date.logecho "=========================================================================" >> /tmp/$(hostname)_quarterly_check_$cur_date.log#注意需要提前安装expect#自动上传log到SFTPtargetServerUser=infratargetserverIP=172.16.16.1targetServerPasswd='Password@123!'expect
上一篇:和平精英下载教程