交互双引号较长变量
#!/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 [email protected]$Ip {$Cmd}; expect { password: { send_user RemotePasswd\n send ${RemotePasswd}\r; interact; } eof { send_user eof\n } } "