From: Samuel Tardieu <sam@ada.eu.org>
Subject: Re: help about execute a command
Date: 1998/08/07
Date: 1998-08-07T00:00:00+00:00 [thread overview]
Message-ID: <m3pvedt52j.fsf@zaphod.enst.fr> (raw)
In-Reply-To: 6qddcf$2mr$1@nnrp1.dejanews.com
> I am learning ADA 95 with gnat 3.10 under linux, and I must write a
> program that executes a command of the operating system such as
> ls,insmod , cp ... Is that possible ? Thanks in advance !
This is really a FAQ... Here is an untested version of a function
(Spawn) which does this in Ada[1].
Sam
Footnotes:
[1] Note the capitalization, it's not ADA
--
Samuel Tardieu -- sam@ada.eu.org
function Spawn (Command : String) return Integer;
-- Spawn a command and return its exit status
with Interfaces.C.Strings; use Interfaces.C, Interfaces.C.Strings;
function Spawn (Command : String) return Integer is
function C_System (Command : chars_ptr) return int;
pragma Import (C, C_System, "system");
C_Command : chars_ptr := New_String (Command);
Code : constant int := C_System (C_Command);
begin
Free (C_Command);
return Integer (Code / 256);
end Spawn;
prev parent reply other threads:[~1998-08-07 0:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-08-06 0:00 help about execute a command jtapasai
1998-08-07 0:00 ` Robert Dewar
1998-08-07 0:00 ` Jerry van Dijk
1998-08-07 0:00 ` Samuel Tardieu [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox