From: "Jens K S" <jens.schoedt@gmail.com>
Subject: how to use GNAT.Expect
Date: 24 Jul 2006 08:14:57 -0700
Date: 2006-07-24T08:14:57-07:00 [thread overview]
Message-ID: <1153754097.448111.251710@b28g2000cwb.googlegroups.com> (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
next reply other threads:[~2006-07-24 15:14 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-24 15:14 Jens K S [this message]
2006-07-24 17:15 ` how to use GNAT.Expect 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
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox