This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: expect script hanging: ssh to localhost w/password authentication


Sorry/MY MISTAKE - the test case was unfair, it was done from a bash
session at the console. The test case at the console may not have worked
for the last several cygwin releases. The test case *does* work just
fine when initiated from an ssh session.

I guess this comes down to - *nevermind*!  The failure to
work from a console session is not a regression AFAIK.

--
For what it's worth, here is the console test case (fails), and 
the *working* ssh session test case:

On Sun 1/8/06 11:09 CST cygwin@cygwin.com wrote:
> The expect script listed earlier in this thread is failing
> for me again, with the 1/7/2006 snapshot. It does not hang though - will
> post details later.

it *does* hang now (from console only) since I added the line "set timeout -1"

> I wonder if the snapshot fix related to:
>   http://sourceware.org/ml/cygwin/2006-01/msg00183.html 
> may account for this? I'm grateful for the fix above (*really*), but
> could it have resurrected the expect script problem? - admittedly a WAG.
> 
>   Sorry, I'm "out of the loop"; have not been following the
>   cygwin mailing list for about a week.. 
> 
> When I get time, I will post simple log of the failing expect script test case.

I used the same script as before, but added the line "set timeout -1".
For the console case, "expect" never recognizes the password prompt from
sshd, even though this prompt is visible on the console (where I did
the 1st test below).

Here's the console test case:

  $ uname -a
  CYGWIN_NT-5.0 OurServer108 1.5.19s(0.149/4/2) 20060107 13:00:49 i686 unknown unknown Cygwin
  $ cat /tmp/fum
  #!/usr/bin/expect
  exp_internal 1
    #to turn on debugging

  set timeout -1
  set env(TERM) "vt100"

  set USER staffuser1
  set PASSWORD "MYPASSWORDWASHERE"

  set prompt " $USER >"
    # adjust prompt as required

  spawn ssh localhost -l $USER

  expect "assword:"
  send "$PASSWORD\r"

  expect $prompt
  # --------------------------------------------------------------------
  # launch command with the next send below:
  #   exit the shell after running command
  # --------------------------------------------------------------------

  send "date; exit\r"

  expect; # waits for eof, so output is flushed?
  puts "\n\nexpect script exiting normally\n";
  $ /tmp/fum
  spawn ssh localhost -l staffuser1
  parent: waiting for sync byte
  parent: telling child to go ahead
  parent: now unsynchronized from child
  spawn: returns {5932}

  expect: does "" (spawn_id 4) match glob pattern "assword:"? no
  staffuser1@localhost's password:
  --SNIP (expect hangs here, until I kill the spawned ssh)

  For my cygcheck output see
    http://sourceware.org/ml/cygwin/2005-12/txt00021.txt

Here's the "working-fine" test case initiated from a prexisting ssh session:

  $ uname -a
  CYGWIN_NT-5.0 OurServer108 1.5.19s(0.149/4/2) 20060107 13:00:49 i686 unknown unknown Cygwin
  $ /tmp/fum
  spawn ssh localhost -l staffuser1
  parent: waiting for sync byte
  parent: telling child to go ahead
  parent: now unsynchronized from child
  spawn: returns {6416}

  expect: does "" (spawn_id 4) match glob pattern "assword:"? no
  staffuser1@localhost's password:
  expect: does "staffuser1@localhost's password: " (spawn_id 4) match glob pattern "assword:"? yes
  expect: set expect_out(0,string) "assword:"
  expect: set expect_out(spawn_id) "4"
  expect: set expect_out(buffer) "staffuser1@localhost's password:"
  send: sending "MYPASSWORDWASHERE" to { 4 }

  expect: does " " (spawn_id 4) match glob pattern " staffuser1 >"? no


  expect: does " \r\n" (spawn_id 4) match glob pattern " staffuser1 >"? no
  Last login: Sun Jan  8 12:44:04 2006 from 127.0.0.1
  Welcome to Engineering Systems tcm server ..

  expect: does " \r\nLast login: Sun Jan  8 12:44:04 2006 from 127.0.0.1\r\r\nWelcome to Engineering Systems tcm server ..\r\n" (spawn_id 4) match glob pattern " staffuser1 >"? no
  > 12:44:45 Sun Jan 08 0j tty3 2728 ~
  > OurServer108 staffuser1 >
  expect: does " \r\nLast login: Sun Jan  8 12:44:04 2006 from 127.0.0.1\r\r\nWelcome to Engineering Systems tcm server ..\r\n> 12:44:45 Sun Jan 08 0j tty3 2728 ~\r\r\n> OurServer108 staffuser1 > " (spawn_id 4) match glob pattern " staffuser1 >"? yes
  expect: set expect_out(0,string) " staffuser1 >"
  expect: set expect_out(spawn_id) "4"
  expect: set expect_out(buffer) " \r\nLast login: Sun Jan  8 12:44:04 2006 from 127.0.0.1\r\r\nWelcome to Engineering Systems tcm server ..\r\n> 12:44:45 Sun Jan 08 0j tty3 2728 ~\r\r\n> OurServer108 staffuser1 >"
  send: sending "date; exit\r" to { 4 }
  date; exit
  Sun Jan  8 12:44:46 CST 2006
  logout
  Connection to localhost closed.
  expect: read eof
  expect: set expect_out(spawn_id) "4"
  expect: set expect_out(buffer) " date; exit\r\nSun Jan  8 12:44:46 CST 2006\r\nlogout\r\nConnection to localhost closed.\r\r\n"


  expect script exiting normally

  $
--snip
> On Tue 12/20/05 22:01 +0100 cygwin@cygwin.com wrote:
> > On Dec 19 11:00, Tom Rodman wrote:
> > > Enclosed is an expect script (to ssh to the localhost with password
> > > authentication) that "hangs" (search ahead for "parent: waiting for sync byte")
> > > with the Dec 16 snapshot. Please take a look at the working and
> > > non-working test cases below.
> > 
> > Looks like we found the cause for this effect.  Please try
> > the next developers snapshot (2005-Dec-20 and later) from
> > http://cygwin.com/snapshots/
> > 
> > 
> > Thanks for the report,
> > Corinna
--snip


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]