From: "Stéphane Rivière" <stef@genesix.org>
Subject: Re: Is it possible to redirect text output to a String or Unbounded_String?
Date: Thu, 10 Jun 2021 16:42:39 +0200 [thread overview]
Message-ID: <s9t8cv$2kc$1@dont-email.me> (raw)
In-Reply-To: <331aa8fb-271a-4a3a-b95e-d10733cbc404n@googlegroups.com>
Le 10/06/2021 à 04:17, Jerry a écrit :
> Is it possible to redirect text output to a String or Unbounded_String
rather than to a file?
Hi Jerry,
I'm not shure to yunderstand your need... If your goal is to redirect
(catch) the text output of a command system to an Ada variable...
Page 33 in :
https://stef.genesix.org/pub/ada/aide/sow%20-%20v20%20Ada%20Library%20User%20Manual%20v28.pdf
7.9 Shell_Execute
• Description
Executes shell command. Return the exit code if passed from the executed
com-mand. Without Output parameter, the command console output is
displayed by default but can be redirected. If Output is used, then the
executed command output is return in this parameter.
code is in v20.sys.ad* in https://stef.genesix.org/pub/ada/aide/v20-0.3.zip
Notes :
VString is Unbounded_String
package GE renames GNAT.Expect;
package GOL renames GNAT.OS_Lib;
Body (abstract)
procedure Shell_Execute_Output (Command : String;
Result : out Integer;
Output : out VString) is
Arguments : GOL.Argument_List_Access;
Command_Exit_Code : aliased Integer; -- Must reside in memory
(pointer)
begin
if Command /= "" then
Arguments := GOL.Argument_String_To_List (Command);
Output := To_VString (GE.Get_Command_Output
(Command => Arguments (Arguments'First).all,
Arguments => Arguments (Arguments'First + 1 ..
Arguments'Last),
Input => "",
Status => Command_Exit_Code'Access));
GOL.Free (Arguments);
else
Output := +"";
end if;
Result := Command_Exit_Code;
end Shell_Execute_Output;
procedure Shell_Execute_Output (Command : VString;
Result : out Integer;
Output : out VString) is
begin
Shell_Execute_Output (To_String (Command), Result, Output);
end Shell_Execute_Output;
--
Be Seeing You
Number Six
next prev parent reply other threads:[~2021-06-10 14:42 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-10 2:17 Is it possible to redirect text output to a String or Unbounded_String? Jerry
2021-06-10 6:50 ` Simon Wright
2021-06-10 7:00 ` Dmitry A. Kazakov
2021-06-11 13:07 ` Stephane Carrez
2021-06-10 8:31 ` ytomino
2021-06-10 9:09 ` Jeffrey R. Carter
2021-06-10 14:42 ` Stéphane Rivière [this message]
2021-06-11 6:51 ` Stéphane Rivière
2021-06-10 17:06 ` Marius Amado-Alves
2021-06-10 21:12 ` Shark8
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox