1 筛选对应文件路径。网络
2 循环copy文件到指定主机目录。ide
执行文件:getFileList.shspa
#!/bin/shget
for file in $(ls /uploads/video/201706* )test
doList
echo $filefile
./test.sh $file循环
sleep 1im
done脚本
ls /uploads/video/201706* 是筛选uploads/video目录下 201706开始的全部文件
for file in xxx
do
xxx
done
是循环获取文件路径,并执行相应操做
./test.sh $file 是调用test.sh 脚本去跨机器copy文件
执行文件: test.sh
执行用法: ./test.sh xxx(操做文件路径)
#! /usr/bin/expect -f
set timeout -1
set src_file [lindex $argv 0]
spawn scp $src_file root@192.168.0.3:/home/videoTmp
expect "*password:"
send "bszh2016\r"
expect eof
set timeout -1
设置copy文件的网络超时时间
set src_file [lindex $argv 0]
获取输入的文件路径
spawn scp $src_file root@192.168.0.3:/home/videoTmp
经过spawn 命令执行 scp 命令
expect "*password:"
确认输入项
send "bszh2016\r"
输入项内容
expect eof
结束操做