I have a expect script which when uses a procedure to spawn SSH and, later using expect doesn't work, when ssh spawn is directly used, the expect thing seems to work fine. Any idea what can be wrong here ??
I am using the same code snippet in the other case and works fine.
proc sshLogin {serverName userName password} {
global logfd
set timeout 10
logMessage "Connecting to server = $serverName, please wait..."
log_user 0
spawn -noecho ssh -X "$userName\@$serverName"
expect {
"password:" {
send "$password\r"
expect {
"]#" {
log_user 1
logMessage "Logged in to Server = $serverName"
return 1
}
"Permission denied" {
log_user 1
logMessage "Incorrect password!"
}
}
}
timeout {
log_user 1
logMessage "Connection to $serverName timed out"
}
eof {
log_user 1
logMessage "Connection to $serverName failed!"
}
}
return 0
}