#!/usr/bin/expect -f
set host $1
set passwd $2
set name root
#for host in "$1"
#for passwd in "$2"
spawn ssh $host -l $name
expect "root@$host’s password:"
send "$passwd\r"
send"uname\n"
expect"LINUX"
send_user"success"
expect"Permission denied,please try again."
send_user"wrongnumber"
传入的两个参数是目标ip和密码,实现自动ssh的功能,是不是因为用了expect导致了这种情况?
错误如下:
can't read "1": no such variable
while executing
"set host $1"
(file "/home/hht/workspace/work1/ssh1.sh" line 2)