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: console-started expect script hanging: ssh to localhost..works w/new snapshot


On Sun 1/8/06 at 13:13 CST I wrote:
--snip
> The test case at the console may not have worked for the last several cygwin releases. 
--snip

It's working just fine at the console under the 1/8/06 snapshot :->

--
Thanks!
Tom Rodman

--
At the risk of wasting bandwidth, here are the test cases to show this:

>From the console:

  $ uname -a
  CYGWIN_NT-5.0 OurServer108 1.5.19s(0.149/4/2) 20060108 16:34:18 i686 unknown unknown Cygwin
  $ : this is a console session
  $ 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 "PASSWORDWASHERE"

  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 {5448}

  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 "PASSWORDWASHERE\r" 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 18:48:39 2006 from 127.0.0.1
  Welcome to Engineering Systems tcm server ..

  expect: does " \r\nLast login: Sun Jan  8 18:48:39 2006 from 127.0.0.1\r\r\nWelcome to Engineering Systems tcm server ..\r\n" (spawn_id 4) match glob pattern " staffuser1 >"? no
  > 18:53:30 Sun Jan 08 0j tty3 3188 ~
  > OurServer108 staffuser1 >
  expect: does " \r\nLast login: Sun Jan  8 18:48:39 2006 from 127.0.0.1\r\r\nWelcome to Engineering Systems tcm server ..\r\n> 18:53:30 Sun Jan 08 0j tty3 3188 ~\r\r\n> OurServer108 sc
  mcron > " (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 18:48:39 2006 from 127.0.0.1\r
  \r\nWelcome to Engineering Systems tcm server ..\r\n> 18:53:30 Sun Jan 08 0j tty3 3188 ~\r
  \r\n> OurServer108 staffuser1 >"
  send: sending "date; exit\r" to { 4 }
  date; exit
  Sun Jan  8 18:53:30 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 18:53:30 CST 2006\r\nlogout\r\nConnection to localhost closed.\r\r\n"


  expect script exiting normally

  $ : worked fine!
  --snip
  $ ssh localhost '/bin/date;cmd /c netstat -n|/bin/head' #manually entered password
  staffuser1@localhost's password:
  Sun Jan  8 18:55:39 CST 2006

  Active Connections

    Proto  Local Address          Foreign Address        State
    TCP    10.160.5.180:22        10.165.10.182:49213   ESTABLISHED
    TCP    10.160.5.180:445       10.160.5.191:3328      ESTABLISHED
    TCP    10.160.5.180:445       10.160.5.192:1063      ESTABLISHED
    TCP    10.160.5.180:1092      10.160.5.180:5413      ESTABLISHED
    TCP    10.160.5.180:1098      10.160.5.180:4139      ESTABLISHED
    TCP    10.160.5.180:1098      10.160.5.180:4148      ESTABLISHED
  $ : also worked fine

>From an ssh session:

  $ uname -a
  CYGWIN_NT-5.0 OurServer108 1.5.19s(0.149/4/2) 20060108 16:34:18 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 "PASSWORDWASHERE"

  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 {5116}

  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 "PASSWORDWASHERE\r" 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 18:47:27 2006 from 127.0.0.1
  Welcome to Engineering Systems tcm server ..

  expect: does " \r\nLast login: Sun Jan  8 18:47:27 2006 from 127.0.0.1\r\r\nWelcome to Engineering Systems tcm server ..\r\n" (spawn_id 4) match glob pattern " staffuser1 >"? no
  > 18:48:40 Sun Jan 08 0j tty3 3188 ~
  > OurServer108 staffuser1 >
  expect: does " \r\nLast login: Sun Jan  8 18:47:27 2006 from 127.0.0.1\r\r\nWelcome to Engineering Systems tcm server ..\r\n> 18:48:40 Sun Jan 08 0j tty3 3188 ~\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 18:47:27 2006 from 127.0.0.1\r\r\nWelcome to Engineering Systems tcm server ..\r\n> 18:48:40 Sun Jan 08 0j tty3 3188 ~\r\r\n> OurServer108 staffuser1 >"
  send: sending "date; exit\r" to { 4 }
  date; exit
  Sun Jan  8 18:48:40 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 18:48:40 CST 2006\r\nlogout\r\nConnection to localhost closed.\r\r\n"


  expect script exiting normally

  $ : worked fine
  $ ssh localhost date #manually entered password
  staffuser1@localhost's password:
  Sun Jan  8 18:49:10 CST 2006
  $ : worked fine


--
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]