comp.lang.ada
 help / color / mirror / Atom feed
* how to use GNAT.Expect
@ 2006-07-24 15:14 Jens K S
  2006-07-24 17:15 ` Samuel Tardieu
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Jens K S @ 2006-07-24 15:14 UTC (permalink / raw)


Hi all,

I new to Ada and I've been fiddling with this problem for too long
now.
Basically I want to transfer some files using Ada, but since I don't
want to create my own FTP implementation I want to start a new FTP
process from Ada (I use echo in example below). Works fine with
GNAT.OS_Lib, but when I use GNAT.Expect I get no output and an
exception?? What am I doing wrong here?

By the way, I use Xcode on OS X. Does anyone know how I can "Step
Into" code in the Expect package? This could also help me locate the
problem....

-------------------------- code -------------------------------
with Ada.Text_io;
use Ada.Text_io;
with GNAT.Expect;
with GNAT.OS_Lib;

procedure ClonesTest is

	Fd: GNAT.Expect.Process_Descriptor;
	Timeout: Integer := 10000; -- 10 sec
	Result: GNAT.Expect.Expect_Match;
	Sucess: boolean;
	P: GNAT.OS_Lib.Process_Id;
begin

	-- using Lib
	P:= GNAT.OS_Lib.Non_Blocking_Spawn("/bin/echo", (1 => new String'
("from Lib Non_Block")));
	GNAT.OS_Lib.Spawn ("/bin/echo", (1 => new String' ("from Lib Block")),
Sucess);

	-- using Expect
	GNAT.Expect.Non_Blocking_Spawn (Fd, "/bin/echo", (1 => new String'
("from Expect")));
	GNAT.Expect.Expect (Fd, Result, ".*", Timeout);
	Put_Line ("Seen: " & GNAT.Expect.Expect_Out (Fd));

    Put_Line("Hello, World again with Ada!");

end ClonesTest;


--------------- Output ---------------

from Lib Non_Block
from Lib Block

raised GNAT.EXPECT.PROCESS_DIED : g-expect.adb:594

ClonesTest has exited with status 1. 


Thanks in advance

Jens




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

end of thread, other threads:[~2006-07-28 18:23 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-07-24 15:14 how to use GNAT.Expect Jens K S
2006-07-24 17:15 ` Samuel Tardieu
2006-07-24 18:52   ` Jens K S
2006-07-25  7:33     ` Samuel Tardieu
2006-07-25  8:51     ` Alex R. Mosteo
2006-07-25 18:40       ` Jens K S
2006-07-24 19:36 ` Simon Wright
2006-07-28 18:23 ` Jens K S

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