delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2006/01/08/21:48:44

X-Spam-Check-By: sourceware.org
Message-Id: <200601090248.k092mTBb027769@tigris.pounder.sol.net>
From: cygwin AT trodman DOT com (Tom Rodman)
Reply-to: cygwin AT cygwin DOT com
To: cygwin AT cygwin DOT com
Subject: Re: console-started expect script hanging: ssh to localhost..works w/new snapshot
In-reply-to: <200601081913.k08JDjGO025952@tigris.pounder.sol.net>
References: <200512191700 DOT jBJH0Qw9019385 AT tigris DOT pounder DOT sol DOT net> <20051220210122 DOT GQ2965 AT calimero DOT vinschen DOT de> <200601081709 DOT k08H9vJ7025427 AT tigris DOT pounder DOT sol DOT net> <200601081913 DOT k08JDjGO025952 AT tigris DOT pounder DOT sol DOT net>
Date: Sun, 08 Jan 2006 20:48:28 -0600
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

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 AT localhost's password:
  expect: does "staffuser1 AT 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 AT 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 AT 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 AT localhost's password:
  expect: does "staffuser1 AT 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 AT 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 AT 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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019