comp.lang.ada
 help / color / mirror / Atom feed
From: Larry Hazel <Larry.H.Hazel@cpmx.saic.com>
To: Markus Wahl <d95wahl@dtek.chalmers.se>
Subject: Re: Pipe UNIX-commands
Date: 1996/08/21
Date: 1996-08-21T00:00:00+00:00	[thread overview]
Message-ID: <321B21B2.1F32@cpmx.saic.com> (raw)
In-Reply-To: Pine.SOL.3.92.960820123945.4995D-100000@gilmer.dtek.chalmers.se


Markus Wahl wrote:
> 
> I'd like to know how I can make unix-commands from inside my ada-program.
> 
> Eg: The program shall pipe out the command 'ls' and then make something
> within the program with the output of 'ls'. Am I clear?

I don't remember the details of the unix system call, I think it may be
'system' (try 'man system' to check it out).  I no longer have access to
unix.  Anyway, you can import this C function and run any command from
your Ada program that you can run from the shell prompt and can include
I/O redirection.  Something like:

with Interfaces.C;

   procedure Execute_Unix_Command (Command_Line :
Interfaces.C.Char_Array);
   pragma Import (C, Execute_Unix_Command, "system");

   ...

   Execute_Unix_Command (Interfaces.C.To_C ("ls > result_file"));

Now you can open result_file with Text_IO and read it.  There are
probably other ways.

Hope this helps

-- Larry Hazel => Larry.H.Hazel@cpmx.saic.com (205) 876-4509
-- I try to stay above C level,  I get C sick.
-- Team Ada & Team OS/2




  reply	other threads:[~1996-08-21  0:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-08-20  0:00 Pipe UNIX-commands Markus Wahl
1996-08-21  0:00 ` Larry Hazel [this message]
1996-08-23  0:00   ` Markus Wahl
1996-08-21  0:00 ` Stephen & Tammy House
  -- strict thread matches above, loose matches on Subject: below --
1996-07-04  0:00 Markus Wahl
replies disabled

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