system("ls ");
or in JAVA
exec("ls");
Is there some similar way of calling a system command in ADA?
Thanks in advance
The easiest way is to simply call the C system command.
The example below was run on my Windows XP system.
with Interfaces.C.Strings;
use Interfaces.C.Strings;
procedure System_Example is
function System_Call(Command : Chars_Ptr) return Interfaces.C.Int;
pragma Import(Convention => C, Entity => System_Call,
External_Name => "system");
Rc : Interfaces.C.Int;
begin
Rc := System_Call(New_String("dir"));
end System_Example;
The important part of the example is the creation of a function
specification I have named System_Call. That function specification
take a parameter of Chars_Ptr, which corresponds to a C char *.
The function specification is used as the Ada interface to the C
system call. The compiler is notified of that association through
the pragma Import. That pragma causes the compiler to link the C
system command and call it whenever System_Call is called in the
Ada code.
Jim Rogers
Aldebaran
--
Michel Simeon
<jimmaure...@worldnet.att.net> wrote in message
news:1150031952.3...@i40g2000cwc.googlegroups.com...
See GNAT.OS_Lib.Non_Blocking_Spawn, GNAT.Expect.Non_Blocking_Spawn.
--
Ludovic Brenta.
I had not realized that in addition to Ada per se I should also look into
what GNAT is offering.
--
Michel Simeon
"Ludovic Brenta" <lud...@ludovic-brenta.org> wrote in message
news:1150380670....@y41g2000cwy.googlegroups.com...