comp.lang.ada
 help / color / mirror / Atom feed
* Running external programs in ADA.
@ 1999-02-25  0:00 Matthew Butt
  1999-02-25  0:00 ` David C. Hoos, Sr.
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Matthew Butt @ 1999-02-25  0:00 UTC (permalink / raw)


Hi all...

Does anyone know how I can call an external program in Ada?

I need to do a bit of text processing, call a UNIX command and then do a
bit more processing and call another program.

Any suggestions welcomed warmly!!


______  ___      __________
___   |/  /_____ __  /__  /_  Matthew Butt
__  /|_/ /_  __ `/  __/  __/  m.a.butt@scm.brad.ac.uk
__ /  / / / /_/ // /_ / /_    ICQ #2527620
/_/  /_/  \__,_/ \__/ \__/    www.student.comp.brad.ac.uk/~mabutt







^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Running external programs in ADA.
  1999-02-25  0:00 Running external programs in ADA Matthew Butt
@ 1999-02-25  0:00 ` David C. Hoos, Sr.
  1999-02-25  0:00 ` dennison
  1999-02-25  0:00 ` Steve Quinlan
  2 siblings, 0 replies; 4+ messages in thread
From: David C. Hoos, Sr. @ 1999-02-25  0:00 UTC (permalink / raw)



Matthew Butt wrote in message ...
>Hi all...
>
>Does anyone know how I can call an external program in Ada?
>
>I need to do a bit of text processing, call a UNIX command and then do a
>bit more processing and call another program.
>
Well... you need to define the problem more completely.

Ada can do all of the things a C program can do.  For example, it can execute
a shell command via the "system" C-library function, or "fork," wait for child
process completion, etc., etc.

Here are (at least some of) the questions that need to be answered, viz.:

   1.  Do you need to wait until the UNIX command completes before proceeding?
   2.  Do you need results from the UNIX command to be used in your continued processing?
   3.  If the answer to (2.) is "yes," are these results binary or text, and how do you
       propose to communicate them?
   4.  You speak of "UNIX command" and "another program."  Are these terms as used by you
       synonymous?








^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Running external programs in ADA.
  1999-02-25  0:00 Running external programs in ADA Matthew Butt
  1999-02-25  0:00 ` David C. Hoos, Sr.
  1999-02-25  0:00 ` dennison
@ 1999-02-25  0:00 ` Steve Quinlan
  2 siblings, 0 replies; 4+ messages in thread
From: Steve Quinlan @ 1999-02-25  0:00 UTC (permalink / raw)


In the simplest case, you would define a function  spec:

function system (cmd : in string) return integer;
and implement it by pragma import (C, system).

Pass the command to be executed in the cmd parameter, adding an "&" if you
don't want to block, (and an ASCII nul always).

To be more correct, use the appropriate types out of interfaces.C(.*) for
int and string. That helps in converting Ada strings to C char arrays.

Check your system to see which shell the system call executes the command
under -- this can make a difference!






^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Running external programs in ADA.
  1999-02-25  0:00 Running external programs in ADA Matthew Butt
  1999-02-25  0:00 ` David C. Hoos, Sr.
@ 1999-02-25  0:00 ` dennison
  1999-02-25  0:00 ` Steve Quinlan
  2 siblings, 0 replies; 4+ messages in thread
From: dennison @ 1999-02-25  0:00 UTC (permalink / raw)


In article <Pine.SOL.4.02A.9902251428030.18391-100000@dcsun2.comp.brad.ac.uk>,
  Matthew Butt <mabutt@dcsun2.comp.brad.ac.uk> wrote:
> Hi all...
>
> Does anyone know how I can call an external program in Ada?
>
> I need to do a bit of text processing, call a UNIX command and then do a
> bit more processing and call another program.

Sure. First, figure out what system calls/library calls you would need to do
that in C. Second, call those routines from Ada. Ada can mimic C's calling
conventions, and thus can call any subroutine that was intended for C that can
be linked in.

If you don't know how to do this in C either, what you really have is a Unix
question, not an Ada question. We might be able to help with that too (if you
tell us what Unix flavor/platform you have), or you could ask in an
appropriate Unix newsgroup.


T.E.D.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~1999-02-25  0:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-02-25  0:00 Running external programs in ADA Matthew Butt
1999-02-25  0:00 ` David C. Hoos, Sr.
1999-02-25  0:00 ` dennison
1999-02-25  0:00 ` Steve Quinlan

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