交互式

#!/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 "   

你可能感兴趣的:(linux)