Linux 使用expect工具和scp命令实现自动复制传输文件
来源:互联网 发布:小白菜新店提取软件 编辑:程序博客网 时间:2024/06/10 13:06
新建copy_file.exp文件
文件内容如下:
#!/usr/expect/bin/expect############################################################## # # 1.Copy install-package to destination host ## ################################################################ check parameter numbers #if {$argc < 8} {puts " Error : Parameter is error."puts " Usage : ./copy_file.exp local_file_path local_file_name remote_user remote_host remote_host_password remote_file_path remote_file_name local_to_remote:0|1"puts "Example: ./copy_file.exp /home/uxdb test.zip uxdb 192.168.1.234 123456 /home/uxdb test.zip 0"exit 1}set local_file_path [lindex $argv 0]set local_file_name [lindex $argv 1]set remote_user [lindex $argv 2]set remote_host [lindex $argv 3]set remote_host_password [lindex $argv 4]set remote_file_path [lindex $argv 5]set remote_file_name [lindex $argv 6]set local_to_remote [lindex $argv 7]set timeout 5set copy_timeout 60 ;#复制文件超时时间:60秒## check local_to_remote parameter#if {$local_to_remote != 0 && $local_to_remote != 1} {puts "The last parameter is failed,please input 0 or 1"exit 1}## start to copy#if {$local_to_remote == 0} {set filename $local_file_namespawn scp $local_file_path/$local_file_name $remote_user@$remote_host:$remote_file_path/$remote_file_name} else {set filename $remote_file_namespawn scp $remote_user@$remote_host:$remote_file_path/$remote_file_name $local_file_path/$local_file_name}expect {"*(yes/no)?" {send "yes\r"exp_continue }"*password:" {send "$remote_host_password\r"}}expect {"Host key verification failed." {puts "\rverify failed!"exit 1}"Permission denied*" {puts "\rpassword is error!"exit 1}"$filename" {}}set timeout $copy_timeoutexpect eof {puts "\r******** copy finished! **********"}
阅读全文
0 0
- Linux 使用expect工具和scp命令实现自动复制传输文件
- 使用expect脚本实现scp远程传输
- Linux SCP命令复制传输文件的用法
- linux,scp传输文件用expect工具免密码输入shell脚本
- 【Linux命令】scp传输文件
- 使用scp命令传输文件
- linux使用shell脚本实现自动登录scp传输文件到其他服务器
- 在shell脚本中使用expect实现scp传输问题
- Linux 服务器间 传输文件 scp 命令 使用详解
- linux下远程传输文件命令scp使用注解
- Linux 利用 expect 进行 scp 自动同步文件
- Linux跨服务器复制文件 scp命令的使用
- Linux之间传输文件(scp命令)
- linux远程传输文件scp命令
- linux系统之间传输文件-SCP命令
- 怎么使用scp在Linux和window之间传输文件
- Linux SCP 基于expect密码传输
- linux的复制文件命令scp
- 1072. 开学寄语(20)
- navicat提权的两个方法(注册表+星号查看器)
- 67 个节省开发者时间的实用工具、库与资源(前端向)
- VMware Workstation Pro 12.5.7虚拟机安装 MAC OS X El Capitan 10.11.1 (15B42).cdr懒人版
- java中有自动回收机制,为什么有时候还写程序回收?
- Linux 使用expect工具和scp命令实现自动复制传输文件
- Android 手机卫士(9)安装从服务器端下载好的APK
- 1013 三的幂的和
- base64编码之去除特殊字符
- 2.20 资源管理
- JBPM6.3环境搭建
- C# event 和delegate的区别
- python 局部变量和全局变量 global
- Vue2 标签内容拓展slot