* help about execute a command
@ 1998-08-06 0:00 jtapasai
1998-08-07 0:00 ` Robert Dewar
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: jtapasai @ 1998-08-06 0:00 UTC (permalink / raw)
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 !
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: help about execute a command
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
2 siblings, 0 replies; 4+ messages in thread
From: Samuel Tardieu @ 1998-08-07 0:00 UTC (permalink / raw)
> 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;
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: help about execute a command
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
2 siblings, 0 replies; 4+ messages in thread
From: Jerry van Dijk @ 1998-08-07 0:00 UTC (permalink / raw)
jtapasai@my-dejanews.com wrote:
: 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 !
with Interfaces.C;
procedure Show is
function System (Cmd : String) return Integer is
function C_System (S : Interfaces.C.char_array) return Integer;
pragma Import (C, C_System, "system");
begin
return C_System (Interfaces.C.To_C (Cmd));
end System;
pragma Inline (System);
Result : Integer;
begin
Result := System ("ls");
end Show;
I notice that the last three question you asked here could all have been
easily answered by looking in the index of an good Ada reference book. I
suggest you really should get one of those books.
My own preference is for 'Ada as a second language' by Norman Cohen.
Jerry.
--
-- Jerry van Dijk | email: jdijk@acm.org
-- Leiden, Holland | member Team-Ada
-- Ada & Win32: http://stad.dsl.nl/~jvandyk
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: help about execute a command
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
2 siblings, 0 replies; 4+ messages in thread
From: Robert Dewar @ 1998-08-07 0:00 UTC (permalink / raw)
jtapasai asks
<<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 !
>>
Have a look at GNAT.OS_Lib.Spawn (in file g-os_lib.ads).
In general if you are using GNAT, look through the g-??????.ads files, there
is quite a bit of useful stuff here, and we are constantly adding new
functionality to this specialized GNAT library.
Robert Dewar
Ada Core Technologies
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~1998-08-07 0:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox