linux 批量scp 脚本
Posted xl-892694298
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux 批量scp 脚本相关的知识,希望对你有一定的参考价值。
scp.sh
#!/bin/sh
ip_list=/home/tools/scp/iplist
src_file=/home/probecheck.sh
dest_file=/home/
username=root
password=123456
cat $ip_list | while read line
do
host_ip=`echo $line | awk ‘print $1‘`
echo "$host_ip"
./scp.exp $host_ip $username $password $src_file $dest_file
done
scp.exp
#!/usr/bin/expect
set timeout 10
set host [lindex $argv 0]
set username [lindex $argv 1]
set password [lindex $argv 2]
set src_file [lindex $argv 3]
set dest_file [lindex $argv 4]
spawn scp $src_file [email protected]$host:$dest_file
expect
"(yes/no)?"
send "yes\n"
expect "*assword:" send "$password\n"
"*assword:"
send "$password\n"
expect "100%"
expect eof
以上是关于linux 批量scp 脚本的主要内容,如果未能解决你的问题,请参考以下文章