This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] New subprogram GNAT.Expect.Get_Command_Output


Tested on i686-linux, committed on mainline.

This change adds a new subprogram that allows the user
to have a command executed and get its stdout back as a String.
Test case: the program below must produce this output:
--
Hello world
exit status: 0
----------
gcc: no input files
exit status: 1
--
with GNAT.Expect;
with Ada.Text_IO;
procedure Demo is
   Status : aliased Integer;
begin
   Ada.Text_IO.Put_Line (GNAT.Expect.Get_Command_Output
     ("/bin/echo", (1 => new String'("Hello"), 2 => new String'("world")),
      "", Status'Access));
   Ada.Text_IO.Put_Line ("exit status:" & Status'Img);
   Ada.Text_IO.Put_Line ("----------");
   Ada.Text_IO.Put_Line (GNAT.Expect.Get_Command_Output
     ("gcc", (1 .. 0 => null),
      "", Status'Access, Err_To_Out => True));
   Ada.Text_IO.Put_Line ("exit status:" & Status'Img);
end Demo;

2005-07-04  Thomas Quinot  <quinot@adacore.com>

	* g-expect-vms.adb, g-expect.ads, g-expect.adb
	(Get_Command_Output): New subprogram to launch a process and get its
	standard output as a string.

Attachment: difs.1
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]