From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!q27g2000yqn.googlegroups.com!not-for-mail From: Gautier write-only Newsgroups: comp.lang.ada Subject: Catching Standard_Error with GNAT.Expect Date: Sun, 7 Feb 2010 13:56:32 -0800 (PST) Organization: http://groups.google.com Message-ID: NNTP-Posting-Host: 62.203.253.134 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1265579792 16081 127.0.0.1 (7 Feb 2010 21:56:32 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sun, 7 Feb 2010 21:56:32 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: q27g2000yqn.googlegroups.com; posting-host=62.203.253.134; posting-account=gRqrnQkAAAAC_02ynnhqGk1VRQlve6ZG User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.7) Gecko/20100104 SeaMonkey/2.0.2,gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:8959 Date: 2010-02-07T13:56:32-08:00 List-Id: 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;