Re: ssh script



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.

.



Relevant Pages

  • Re: ssh script
    ... proc nortelnetworks:handler {cmd addr timeout login password cmds} { ... send_user "mot de passe envoye \n" ... send_user "mauvais mot de passe ...
    (comp.lang.tcl)
  • Re: ssh script
    ... proc nortelnetworks:handler {cmd addr timeout login password cmds} { ... send_user "mot de passe envoye \n" ... send_user "mauvais mot de passe ...
    (comp.lang.tcl)
  • Re: ssh script
    ... to get my ssh session with a switch, not a server; ... send_user "mot de passe envoye \n" ... send_user "mauvais mot de passe ...
    (comp.lang.tcl)
  • Re: my computer -> home computer -> work server via ssh
    ... My coworker who maintains the server added my home ... I figured out how to ssh to my home linux, then ssh to my dev server. ... more often than the sleep period specified in the script ... my $lport = undef; ...
    (comp.security.ssh)
  • Re: bash script and SIGHUP
    ... > I was trying to write a small script to start ssh port forwarding and ... > I start the port forwarding, sleep and start x2vnc which allows me to ... Hello Matteo. ...
    (comp.unix.shell)