Re: ssh script
- From: gcharreyron@xxxxxxxxx
- Date: 16 Feb 2007 02:27:49 -0800
On 15 fév, 18:42, "Why Tea" <ytl...@xxxxxxxxx> wrote:
On Feb 15, 2:32 am, gcharrey...@xxxxxxxxx wrote:
On 14 fév, 16:18, "Schubert" <cxbest2...@xxxxxxxxx> wrote:
On Feb 14, 9:10 am, gcharrey...@xxxxxxxxx wrote:
Hello
That's the same problem as mine i think, check my post in this
usergroup please. Someone has already replied, and I am still tring
their approaches.
sorry, but I don't think we have the same problem.
I looked at your posts and many things differ from my situation: I try
to get my ssh session with a switch, not a server; and I can't use
spawn as you since I don't have it, and I am not root.
my script is more like this:
...
proc nortelnetworks:handler {cmd addr timeout login password cmds} {
set lines {}
set count 0
set send_slow {1 0.5}
if {[catch {exp_spawn ${cmd} ${login}@${addr}} err]} {
return ${err}
}
sleep 2
expect {
-nocase -re "${login}@${addr}\'s password:" {
sleep 2
exp_send -s -- "${password}\r"
send_user "mot de passe envoye \n"
}
-nocase -re {[- /a-z]*(denied|invalid).*$} {
set lines
$expect_out(0,string)
send_user "mauvais mot de passe
\n"
}
-nocase -re "enter ctrl-y to begin.*$" {
exp_send -- "\003"
exp_continue
send_user "ctrl-y ok !\n"
}
...
I can't get into the "enter ctrl.." paragraph, although it works with
telnet...!!!
On the contrary, I think the two problems are similar. My guess is
that in both cases, authentication has failed at the SSH server;
therefore subsequent "expects" are irrelevant. An Expect script that
works using telnet will NOT likely work with SSH, not the other way
around unfortunately.
Hello everybody
well I get rid of it... and it works with ssh.
the matter was with the control to send the Ctrl-Y. In fact it's send -
s -- "\x19", and it works...
the authentication worked already fine.
He're is the part of the solved script :
proc nortelnetworks:handler {cmd addr timeout login password cmds} {
set lines {}
set count 0
set send_slow {1 0.5}
if {[catch {exp_spawn ${cmd} ${login}@${addr}} err]} {
return ${err}
}
sleep 2
expect {
-nocase -re "${login}@${addr}\'s password:" {
sleep 2
exp_send -s -- "${password}\r"
send_user "mot de passe envoye \n"
exp_continue
}
-nocase -re {[- /a-z]*(denied|invalid).*$} {
set lines
$expect_out(0,string)
send_user "mauvais mot de passe
\n"
}
-nocase -re "enter ctrl-y to begin.*$" {
sleep 1
exp_send -- "\x19"
send_user "ctrl-y ok !\n"
exp_continue
}
.....
A big thanks to Stefan Finzel for his help.
I know the sleep are not great, I'll try to deal with them later. I
put them 'cause the ssh server of the switch is very slow.
And the pattern .*$ works well with my expect version: 5.40.
.
- References:
- ssh script
- From: gcharreyron
- Re: ssh script
- From: Schubert
- Re: ssh script
- From: gcharreyron
- Re: ssh script
- From: Why Tea
- ssh script
- Prev by Date: Mistake in mixing geometry managers causes inregular behaviour instead of error
- Next by Date: Re: file handling problem on windows with tcl8.4.14
- Previous by thread: Re: ssh script
- Next by thread: TclMagick and GraphicsMagick in a Starkit
- Index(es):
Relevant Pages
|
|