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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ce7e6cb0bec07cff X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-11-06 09:49:45 PST Path: archiver1.google.com!news2.google.com!news1.google.com!newsfeed.stanford.edu!newsfeed.berkeley.edu!ucberkeley!hammer.uoregon.edu!skates!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: retrieve command result Date: 06 Nov 2002 12:46:07 -0500 Organization: NASA Goddard Space Flight Center (skates.gsfc.nasa.gov) Message-ID: References: <3DC946C2.3000505@cnam.fr> NNTP-Posting-Host: anarres.gsfc.nasa.gov Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: skates.gsfc.nasa.gov 1036605428 17257 128.183.235.92 (6 Nov 2002 17:57:08 GMT) X-Complaints-To: usenet@news.gsfc.nasa.gov NNTP-Posting-Date: 6 Nov 2002 17:57:08 GMT User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: archiver1.google.com comp.lang.ada:30478 Date: 2002-11-06T17:57:08+00:00 List-Id: evangeli writes: > hi all > > is it possible to retrieve the result of a command in a variable. > i explain myself: > > ------------------------------------------------------------------ > with GNAT.OS_Lib; > with Ada.Strings.Unbounded; > procedure Test is > ... > my_string : Ada.Strings.Unbounded.unbounded_string; > ... > begin > ... > GNAT.OS_Lib.Spawn("ls", ...); > -- I WOULD LIKE TO GET IN my_string THE RESULT OF THE ls COMMAND > ... > end; > ------------------------------------------------------------------ > > i am under linux with gnat 3.13p. First, upgrade to 3.14p. In general, you need to map the "standard output stream" of the spawned program to a stream that you then read. There is no Standard way to do this, and I see nothing in the GNAT extensions for it either. Linux has a spawn function that allows you to do this (sorry, I don't know what it is called); find it in a Linux reference, import it into Ada, and call it. Ideally, you should figure out how to use Ada.Streams to provide the stream you read from. -- -- Stephe