* Unix Executables
@ 2001-07-10 18:51 Matt Raikes
2001-07-10 20:04 ` Marin David Condic
2001-07-10 21:02 ` M. A. Alves
0 siblings, 2 replies; 3+ messages in thread
From: Matt Raikes @ 2001-07-10 18:51 UTC (permalink / raw)
Is there a way to call a Unix executable(such as gzip) from within my code.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Unix Executables
2001-07-10 18:51 Unix Executables Matt Raikes
@ 2001-07-10 20:04 ` Marin David Condic
2001-07-10 21:02 ` M. A. Alves
1 sibling, 0 replies; 3+ messages in thread
From: Marin David Condic @ 2001-07-10 20:04 UTC (permalink / raw)
There's always a way. Depends on what exactly you had in mind. If you just
want to invoke a program, here's some code cut from a batch of utilities on
my web page (see: http://www.mcondic.com/):
with Interfaces.C;
procedure UTIL.Perform_System_Command (
Command : in String ;
Wait : in Boolean := True ;
Success : out Boolean) is
--
Return_Code : Integer ;
--
function Sys (
Item : in Interfaces.C.Char_Array) return Integer ;
pragma Import (C, Sys, "system") ;
--
package C renames Interfaces.C ;
--
begin
--
if (Wait) then
Return_Code := Sys (
Item => C.To_C ("ksh -c " & '"' & Command & '"'));
else
Return_Code := Sys (
Item => C.To_C ("ksh -c " & '"' & Command & " &" & '"'));
end if ;
--
if (Return_Code /= 0) then
Success := False ;
else
Success := True ;
end if;
--
end UTIL.Perform_System_Command ;
If you want to actually interface to some OS service that is normally got to
via a subprogram call, then perhaps if you post the call (I presume it is
written in C?) we could help you with the appropriate pragmas, linkage, etc.
A Solution Does Exist, but you might need to be a little more specific.
MDC
--
Marin David Condic
Senior Software Engineer
Pace Micro Technology Americas www.pacemicro.com
Enabling the digital revolution
e-Mail: marin.condic@pacemicro.com
Web: http://www.mcondic.com/
"Matt Raikes" <mraikes@vt.edu> wrote in message
news:ab21b49a.0107101051.766f947a@posting.google.com...
> Is there a way to call a Unix executable(such as gzip) from within my
code.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Unix Executables
2001-07-10 18:51 Unix Executables Matt Raikes
2001-07-10 20:04 ` Marin David Condic
@ 2001-07-10 21:02 ` M. A. Alves
1 sibling, 0 replies; 3+ messages in thread
From: M. A. Alves @ 2001-07-10 21:02 UTC (permalink / raw)
To: comp.lang.ada
On 10 Jul 2001, Matt Raikes wrote:
> Is there a way to call a Unix executable(such as gzip) from within my code.
Many ways. Function Posix.System, for example.
-----
package Posix is
function System(Command: String) return Integer;
end Posix;
-----
with Interfaces.C; use Interfaces.C;
with Interfaces.C.Strings; use Interfaces.C.Strings;
package body Posix is
function C_System(Command: chars_ptr) return int;
pragma Import(C, C_System, "system");
function System(Command: String) return Integer is
C_Command : aliased char_array := To_C(Command);
begin
return(Integer(C_System(To_Chars_Ptr(C_Command'Unrestricted_Access))));
end System;
end Posix;
--
,
M A R I O data miner, LIACC, room 221 tel 351+226078830, ext 121
A M A D O Rua Campo Alegre, 823 fax 351+226003654
A L V E S P-4150 PORTO, Portugal mob 351+939354002
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2001-07-10 21:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-07-10 18:51 Unix Executables Matt Raikes
2001-07-10 20:04 ` Marin David Condic
2001-07-10 21:02 ` M. A. Alves
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox