comp.lang.ada
 help / color / mirror / Atom feed
From: Stephen Leake <stephen.a.leake.1@gsfc.nasa.gov>
Subject: Re: retrieve command result
Date: 06 Nov 2002 12:46:07 -0500
Date: 2002-11-06T17:57:08+00:00	[thread overview]
Message-ID: <uof92k2w0.fsf@gsfc.nasa.gov> (raw)
In-Reply-To: 3DC946C2.3000505@cnam.fr

evangeli <evangeli@cnam.fr> 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



  parent reply	other threads:[~2002-11-06 17:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-06 16:43 retrieve command result evangeli
2002-11-06 17:06 ` sk
2002-11-06 17:46 ` Stephen Leake [this message]
2002-11-07  9:43   ` Emmanuel Briot
2002-11-07 13:56     ` Stephen Leake
2002-11-07  1:48 ` Marc A. Criley
2002-11-07 15:46   ` evangeli
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox