linux - How test SSH connectivity with expect script -
i have linux red-hat machine - version 5.x
i want create expect script verify if ssh login remote machine successfully
my test password prompt on remote login ( not want enter password )
its test ssh connectivity
what created until following script
so if password prompt script need return 0
if not script need return 1
the problem script - script return 0 ssh login failed ( no password prompt )
#!/usr/bin/expect set login [lindex $argv 0] set password [lindex $argv 1] set ip [lindex $argv 2] set timeout 10 spawn ssh -o stricthostkeychecking=no $login@$ip expect -re "(password:|word:)" exit 0 expect { timeout {error "incorrect password"; exit 1} eof }
please advice how update script ?
you have enclose condition in 1 expect
as,
set timeout 10 spawn ssh -o stricthostkeychecking=no $login@$ip expect { timeout {puts "timeout happened";exit 0} eof {puts "eof received"; exit 0} -nocase "password:" {puts "ssh connection alive host $ip"; exit 1} }
have @ here resembles question.
Comments
Post a Comment