From: Gautier write-only <gautier_niouzes@hotmail.com>
Subject: Catching Standard_Error with GNAT.Expect
Date: Sun, 7 Feb 2010 13:56:32 -0800 (PST)
Date: 2010-02-07T13:56:32-08:00 [thread overview]
Message-ID: <a996dc2c-ba18-41cd-9812-266f4a5742cc@q27g2000yqn.googlegroups.com> (raw)
Hello again,
I get a nice asynchronous text output piping from an external process
thanks to GNAT.Expect (test code below). Now a last issue: when the
process is speaking through Standard_Error (like the GNAT compiler for
its messages, if I'm not mistaken), nothing make its way to
Expect_Out. Is there any switch to get the Standard_Error messages
piped ? (I guess yes, since GPS is using GNAT.Expect). TIA!
______________________________________________________________
Gautier's Ada programming -- http://gautiersblog.blogspot.com/
__
with Ada.Text_IO; use Ada.Text_IO;
with GNAT.OS_Lib; use GNAT.OS_Lib;
with GNAT.Expect; use GNAT.Expect;
procedure Pipe_test is
Command : constant String := -- a command which should be long to
execute
"gnatmake -f -Pbig_project.gpr";
Pd : Process_Descriptor;
Args : Argument_List_Access;
Result : Expect_Match;
begin
Args := Argument_String_To_List (Command);
Non_Blocking_Spawn
(Pd,
Command => Args (Args'First).all,
Args => Args (Args'First + 1 .. Args'Last),
Buffer_Size => 0);
loop
begin
Expect (Pd, Result, Regexp => "\n", Timeout => 1_000);
case Result is
when Expect_Timeout =>
Put("[timeout]"); -- no output for this time slice
when Expect_Full_Buffer =>
Put("[full]"); -- doesn't happen with buffer size = 0 ?
when 1 =>
Put(Expect_Out(Pd)); -- regexp matched
when others =>
Put("[?]"); -- shouldn't (and doesn't) happen
end case;
exception
when Process_died => Put("[died]"); exit;
end;
end loop;
Put(Expect_Out(Pd));
Close (Pd);
end Pipe_test;
next reply other threads:[~2010-02-07 21:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-07 21:56 Gautier write-only [this message]
2010-02-07 22:11 ` Catching Standard_Error with GNAT.Expect John B. Matthews
2010-02-07 22:21 ` Gautier write-only
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox