comp.lang.ada
 help / color / mirror / Atom feed
* using GNAT.Expect?
@ 2015-04-17 15:20 Stephen Leake
  2015-04-19 14:32 ` briot.emmanuel
  2015-04-20 15:55 ` Stephen Leake
  0 siblings, 2 replies; 3+ messages in thread
From: Stephen Leake @ 2015-04-17 15:20 UTC (permalink / raw)


I'm trying to use GNAT.Expect to run sftp in a spawned process.

It mostly works, but I'm having trouble waiting for the results of a
command properly.

It would be simple if I could always wait for the prompt "sftp>", but
GNAT.Expect doesn't see that until the next command is echoed. I'm
guessing there is some layer that is waiting for a newline.

I'm running on Windows 7. Is there some way to force GNAT.Expect to not
wait for a newline?

Any other suggestions?

I'll try to integrate the sftp code directly, but there is no simple
library for that (curl is too messy when trying to use sftp).

-- 
-- Stephe


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: using GNAT.Expect?
  2015-04-17 15:20 using GNAT.Expect? Stephen Leake
@ 2015-04-19 14:32 ` briot.emmanuel
  2015-04-20 15:55 ` Stephen Leake
  1 sibling, 0 replies; 3+ messages in thread
From: briot.emmanuel @ 2015-04-19 14:32 UTC (permalink / raw)



You did not show any code, so all suggestions will really be guesses.
Make sure you specify Buffer_Size => 0 in the call to Non_Blocking_Spawn.
It is known to help things in a number of cases.
Then it could be an issue with the regular expression used.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: using GNAT.Expect?
  2015-04-17 15:20 using GNAT.Expect? Stephen Leake
  2015-04-19 14:32 ` briot.emmanuel
@ 2015-04-20 15:55 ` Stephen Leake
  1 sibling, 0 replies; 3+ messages in thread
From: Stephen Leake @ 2015-04-20 15:55 UTC (permalink / raw)


Stephen Leake <stephen_leake@stephe-leake.org> writes:

> I'm trying to use GNAT.Expect to run sftp in a spawned process.
>
> It mostly works, but I'm having trouble waiting for the results of a
> command properly.
>
> It would be simple if I could always wait for the prompt "sftp>", but
> GNAT.Expect doesn't see that until the next command is echoed. I'm
> guessing there is some layer that is waiting for a newline.

I worked around this by always sending a second empty command:

      Send (Protocol.Process, Command & LF & LF, Add_LF => False, Empty_Buffer => True);
      --  If we wait long enough, sftp will output:
      --
      --  <command> LF <response> LF <prompt> LF <prompt>
      --
      --  However Expect requires an LF before seeing anything, so the
      --  Expect buffer will contain:
      --
      --  <prompt> <command> LF <response> LF <prompt> LF <prompt>
      --
      --  where the first <prompt> is left over from the previous command.
      --

-- 
-- Stephe


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-04-20 15:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-17 15:20 using GNAT.Expect? Stephen Leake
2015-04-19 14:32 ` briot.emmanuel
2015-04-20 15:55 ` Stephen Leake

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox