#!/bin/bash
#file_name: expect_1.sh
src_host=192.168.1.103
src_pwd=tom@ether
src_path=/home/chi/server2.c
src_user=chi
expect -c "
spawn scp ${src_user}@${src_host}:${src_path} .
expect \"password:\"
send \"${src_pwd}\r\"
expect eof
"
[chi@yitai01 ~]$ ./expect_1.sh
spawn scp chi@192.168.1.103:/home/chi/server2.c .
Address 192.168.1.103 maps to yitai02, but this does not map back to the address - POSSIBLE BREAKIN ATTEMPT!
chi@192.168.1.103's password:
server2.c 100% 1969 1.9KB/s 00:00
bash
看到了吧,不用手工輸入密碼輸入,jiu ke yi copy. this