fix defect 3777

This commit is contained in:
lissav 2013-09-10 14:23:22 -04:00
parent 0c36ee3155
commit ad095fe20c

View File

@ -90,6 +90,7 @@ sub run_remote_shell_api {
my $output;
my $errmsg;
my $ssh_tried=0;
my $nl_tried=0;
if (!$telnet) {
eval {
@ -209,6 +210,18 @@ sub run_remote_shell_api {
$output.="Password is required.\n";
return [1, $output];
}
} else {
# for some switches like BNT, user has to type an extra new line
# in order to get the prompt.
if ($verbose) {
print " add a newline\n";
}
$nl_tried=1;
if (! $t->put(String => "\n",
Errmode => "return")) {
$output.="Login disconnected\n";
return [1, $output];
}
}
if (!$login_done) {
@ -228,13 +241,48 @@ sub run_remote_shell_api {
$output.="Login failed: bad login name or password\n";
return [1, $output];
} else {
if ($t->errmsg) {
$output.= $t->errmsg . "\n";
return [1, $output];
if (!$nl_tried) {
# for some switches like BNT, user has to type an extra new line
# in order to get the prompt.
if ($verbose) {
print " add a newline\n";
}
$nl_tried=1;
if (! $t->put(String => "\n",
Errmode => "return")) {
$output.="Login disconnected\n";
return [1, $output];
}
}
else {
if ($t->errmsg) {
$output.= $t->errmsg . "\n";
return [1, $output];
}
}
}
}
#check if the extra newline helps or not
if (!$login_done) {
#Wait for command prompt
($prematch, $match) = $t->waitfor(Match => "/$prompt/",
Errmode => "return");
if ($verbose) {
print "4. prematch=$prematch\n match=$match\n";
}
if ($match =~ /$prompt/) {
$login_done=1;
} else {
if ($t->errmsg) {
$output.= $t->errmsg . "\n";
return [1, $output];
}
}
}
}
}
}