通过winscp实现一键修改多台机器文件,并执行相应命令的脚本
2013-12-12 16:33
615 查看
思考一个一键修改多台机器的文件,并执行相应命令的脚本,考虑controller是在windows的情况,agent均为linux,需要使用bat脚本
需要先安装一个软件winscp,然后配置该安装文件的目录到环境变量之中。
执行的主bat脚本如下:
需要一个执行命令的script.txt脚本,此处只罗列2台机器,留个思路做备份,如下:
其中call命令式用来远程执行linux的shell命令,所以可以通过put上传文件覆盖后,再通过call来执行某些服务的restart功能,从而做到一键搞定所有操作的功能。
需要先安装一个软件winscp,然后配置该安装文件的目录到环境变量之中。
执行的主bat脚本如下:
set CURRENT_PATH=%~dp0 winscp /script=%CURRENT_PATH%\script.txt /console /privatekey=%CURRENT_PATH%\agentkety.ppk pause
需要一个执行命令的script.txt脚本,此处只罗列2台机器,留个思路做备份,如下:
# Automatically abort script on errors option batch abort # Disable overwrite confirmations that conflict with the previous option confirm off # Connect using a password # open sftp://user:password@example.com -hostkey="ssh-rsa 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx" # Connect echo go open sftp://root@ec2-54-251-107-178.ap-southeast-1.compute.amazonaws.com # Change remote directory cd /opt/apache-jmeter-2.9_2013.3.11/bin # Force binary mode transfer option transfer binary # Download file to the local directory d:\ get nohup.out d:\ put jmeter.log call cat jmeter.log # Disconnect close open sftp://root@ec2-54-251-107-177.ap-southeast-1.compute.amazonaws.com # Change remote directory cd /opt/apache-jmeter-2.9_2013.3.11/bin # Force binary mode transfer option transfer binary # Download file to the local directory d:\ get nohup.out d:\ put jmeter.log call cat jmeter.log # Disconnect close
其中call命令式用来远程执行linux的shell命令,所以可以通过put上传文件覆盖后,再通过call来执行某些服务的restart功能,从而做到一键搞定所有操作的功能。
相关文章推荐
- 一键帮你复制多个文件到多个机器——PowerShell小脚本(内附PS远程执行命令问题解析)
- 在windows cgywinportable上,通过执行linux命令,批量修改文件名称。
- android通过chmod命令实现文件权限修改
- python脚本 对批量机器执行命令和发送文件
- 通过ANT实现jmeter批量执行脚本、生成报告、发送邮件全套build.xml文件
- 通过ANT实现jmeter批量执行脚本、生成报告、发送邮件全套build.xml文件
- 通过ANT实现jmeter批量执行脚本、生成报告、发送邮件全套build.xml文件
- linux 通过shell脚本在本地执行远程机器命令
- python写的批量操作远程主机脚本(命令执行,上传、下载文件)
- 通过shell脚本循环进入目录执行命令的方法
- python:通过python脚本快速执行 bash 命令
- 本机远程执行命令,查看其他机器的文件内容或者文件夹内容
- Discuz!教程之通过简单php文件实现修改主题发帖时间
- Sql Server--通过生成脚本文件实现低版本“向上兼容”
- Android中通过代码实现文件权限的修改(chmod)
- MySQL用source命令执行外部sql脚本文件时出现failed to open file的错误可能之一
- Linux系统裁减之,制作一个极度精简的Linux-2-用脚本实现自动拷贝命令和依赖库文件
- 【ASP.NET 进阶】定时执行任务实现 (定时读取和修改txt文件数字内容,无刷新显示结果)
- Windows下通过bat批处理文件和vbs脚本实现守护进程
- 开机启动程序、脚本(开机执行命令,永久修改MAC)【仅供参考】