#!/bin/bash
Dest_IP=$1
Dest_Password=$2
declare Dest_cmmd=${3:- }
declare file_dir=${4:- }
declare Dest_dir=${4:- }
expect -c "
set timeout 2
spawn ssh -o StrictHostKeyChecking=no $Dest_IP
expect {
\"*Password*\" { send \"$Dest_Password\r\" }
}
set timeout 3
expect \"*:~*#\"
send \"$Dest_cmmd\r\"
set timeout 2
expect eof
"
expect -c "
set timeout 2
spawn scp -o StrictHostKeyChecking=no -r $file_dir $Dest_IP:$Dest_dir
expect {
\"*Password*\" { send \"$Dest_Password\r\" }
}
set timeout 3
expect eof
"
交互式
最新推荐文章于 2024-10-14 16:42:33 发布