Re: pipe buffering

2010-09-23 Thread Aidan Gauland
Neil Jerram neil at ossau.uklinux.net writes:
 Well, as the manual says:
 
  -- Macro: expect clause ...
  [...]   The procedures
  are called in turn after each character is read from the port,
  [...]
 
  The test is successful if the procedure returns a non-false value.
 
 Your lambda returns *unspecified*, which counts as a non-false value.
 So the whole (expect ...) invocation completes after reading just one
 character.

I must've missed that each character bit.

Maybe it would be better to post my original program that would just
hang.  I was only using expect to print debugging messages; my
original program used expect-strings.

--Aidan

#! /usr/bin/guile -s
!#

(use-modules (ice-9 expect))
(use-modules (ice-9 popen))

(define ie-io (open-pipe* OPEN_BOTH
  /usr/bin/telnet
  ienabler.canterbury.ac.nz 259))
(let ((expect-port ie-io))
  (expect-strings
   (^User: (begin (display [snip]\n ie-io) (display gave user)))
   (^passwd: (begin (display [snip]\n ie-io) (display gave passwd)





Re: pipe buffering

2010-09-23 Thread Aidan Gauland
On Wed, Sep 22, 2010 at 09:17:08PM +0100, Neil Jerram wrote:
 Well, as the manual says:
 
  -- Macro: expect clause ...
  [...]   The procedures
  are called in turn after each character is read from the port,
  [...]
 
  The test is successful if the procedure returns a non-false value.
 
 Your lambda returns *unspecified*, which counts as a non-false value.
 So the whole (expect ...) invocation completes after reading just one
 character.

I must've missed that each character bit.

Maybe it would be better to post my original program that would just
hang.  I was only using expect to print debugging messages; my
original program used expect-strings.

--Aidan


signature.asc
Description: Digital signature


Re: pipe buffering

2010-09-22 Thread Neil Jerram
Aidan Gauland aidal...@no8wireless.co.nz writes:

 Then I have a sexp for debugging, which shows that `expect' is getting
 one character at a time from the telnet subprocess, since it only
 prints out Tmatch, instead of Trying [IP address]...

Well, as the manual says:

 -- Macro: expect clause ...
 [...]   The procedures
 are called in turn after each character is read from the port,
 [...]

 The test is successful if the procedure returns a non-false value.

Your lambda returns *unspecified*, which counts as a non-false value.
So the whole (expect ...) invocation completes after reading just one
character.

 Neil



pipe buffering

2010-09-21 Thread Aidan Gauland
I'm trying to write a program using Guile's expect module to
automatically log into a telnet server, perform some action, and log
out.

This is the start of my program...

#! /usr/bin/guile -s
!#

(use-modules (ice-9 expect))
(use-modules (ice-9 popen))

(define ie-io (open-pipe* OPEN_BOTH
  /usr/bin/telnet
  ienabler.canterbury.ac.nz 259))

Then I have a sexp for debugging, which shows that `expect' is getting
one character at a time from the telnet subprocess, since it only
prints out Tmatch, instead of Trying [IP address]...

(let ((expect-port ie-io))
  (expect
   ((lambda (s eof?) (display s))
(display match

I tried (setvbuf ie-io _IOLBF), but that produces the following error.

Backtrace:
In current input:
  18: 0* [setvbuf {#input-output: soft 807be60} 1]

unnamed port:18:1: In procedure setvbuf in expression (setvbuf ie-io _IOLBF):
unnamed port:18:1: Wrong type argument in position 1 (expecting open file
port): #input-output: soft 807be60
ABORT: (wrong-type-arg)

Can anyone offer any advice on how to get expect to see entire lines?

--Aidan

P.S. ienabler.canterbury.ac.nz is on the inside only of my
university's network, but this is what the output looks like up to the
first prompt...

Trying [IP address]...
Connected to ienabler.canterbury.ac.nz.
Escape character is '^]'.
Check Point FireWall-1 Client Authentication Server running on cpgate1
User: 





Re: pipe buffering

2010-09-21 Thread Aidan Gauland
Aidan Gauland aidalgol at no8wireless.co.nz writes:
 I'm trying to write a program using Guile's expect module to
 automatically log into a telnet server, perform some action, and log
 out.
[snip]

I forgot to mention that I'm using Guile 1.8.7.

--Aidan