expect 交互 之双引号较长变量

交互双引号较长变量 

#!/bin/bash
RemoteUser=xuesong12
Ip=192.168.1.2
RemotePasswd=xuesong
Cmd="/bin/echo "$PubKey" > "$RemoteKey"/authorized_keys"

/usr/bin/expect -c "
set timeout 10
spawn ssh -o StrictHostKeyChecking=no $RemoteUser@$Ip {$Cmd};
expect {
    password: {
        send_user RemotePasswd\n
        send ${RemotePasswd}\r;
        interact;
    }
    eof {
        send_user eof\n
    }
}
"

 

posted @ 2018-04-03 17:54  01234567  阅读(265)  评论(0编辑  收藏  举报