comp.lang.ada
 help / color / mirror / Atom feed
From: James Rogers <jimmaureenrogers@worldnet.att.net>
Subject: Re: Yet another question on system calls(newbie question)
Date: Thu, 10 May 2001 16:20:02 GMT
Date: 2001-05-10T16:20:02+00:00	[thread overview]
Message-ID: <3AFAC042.E2477223@worldnet.att.net> (raw)
In-Reply-To: mailman.989509930.7705.comp.lang.ada@ada.eu.org

Torbj�rn Karfunkel wrote:
> 
> Using the pragma Import method of calling non-Ada entities, am I only
> allowed to define functions? How about procedures? What I want to do is
> to create a text file, give this text file as a parameter to a C
> program, and then wait until the C program finishes. By then it will
> have produced another text file that I want to use.
> Can I use a dummy result variable like the 'result' in the following
> (from another mail):
> 
> procedure Command is
> 
>    function C_System(value : String) return integer;
>    pragma Import(
>          C, C_System, "system");
> 
>    result : integer;
> begin
>    result := C_System("pwd ");
>    result := C_System(value => "acdsee D:\work\pictures\BP47.jpg ");
> end Command;
> 

Do you want to "use" the file with Ada, or with some other system
command?

Note that the "system" command in Unix can take a string containing
an entire pipeline, as in the following example:

   result := C_System("ps -ef | grep root");

You can also redirect the output of the command as follows:

   result := C_System("pwd > /tmp/here");

If you want to open a Unix pipe to a system call, and read the
result directly, then look at the example I posted on 
www.adapower.com for using the pipe command.

Note that your last proposal, to call the system command with the
name of an image file, will not work. The system command only
executes files that have executable permissions set. This is not
normally true for image files. 

Jim Rogers
Colorado Springs, Colorado USA



  reply	other threads:[~2001-05-10 16:20 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-05-10 15:44 Yet another question on system calls(newbie question) Torbjörn Karfunkel
2001-05-10 16:20 ` James Rogers [this message]
2001-05-10 21:03   ` Keith Thompson
2001-05-10 21:12     ` James Rogers
2001-05-10 21:12 ` Keith Thompson
2001-05-12  1:30 ` DuckE
  -- strict thread matches above, loose matches on Subject: below --
2001-05-10 19:40 Torbjörn Karfunkel
2001-05-11  7:18 Torbjörn Karfunkel
replies disabled

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