comp.lang.ada
 help / color / mirror / Atom feed
* [Q] Operating System Command Interface
@ 1998-05-05  0:00 John McCabe
  1998-05-05  0:00 ` David C. Hoos, Sr.
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: John McCabe @ 1998-05-05  0:00 UTC (permalink / raw)



Am I right in thinking that, as standard, Ada has no direct perating 
system command interface akin to the C "System" call?

-- 
Best Regards
John McCabe

=====================================================================
Any opinions expressed are mine and based on my own experience. They
  should in no way be taken as the opinion of anyone I am currently
     working with, or of the company I am currently working for.
       If you have a problem with anything I say, SPEAK TO ME!
                (remove "nospam." to reply by e-mail)
=====================================================================






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

* Re: [Q] Operating System Command Interface
  1998-05-05  0:00 [Q] Operating System Command Interface John McCabe
@ 1998-05-05  0:00 ` David C. Hoos, Sr.
  1998-05-05  0:00   ` John McCabe
  1998-05-05  0:00 ` Markus Kuhn
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 12+ messages in thread
From: David C. Hoos, Sr. @ 1998-05-05  0:00 UTC (permalink / raw)



You're right, but the solution is simple.  I use the following library
function:
with Ada.Characters.Latin_1;
with System;
function Execute_Shell_Command
           (The_Command : String) return Integer is
   function Execute
              (The_Command_Address : System.Address) return Integer;
   pragma Import (C, Execute, "system");
   The_Nul_Terminated_Command_String : constant String :=
     The_Command & Ada.Characters.Latin_1.Nul;
begin
   return Execute (The_Nul_Terminated_Command_String'Address);
end Execute_Shell_Command;
David C. Hoos, Sr.

John McCabe wrote in message <6ims5j$1vo@gcsin3.geccs.gecm.com>...
>Am I right in thinking that, as standard, Ada has no direct perating
>system command interface akin to the C "System" call?
>
>--
>Best Regards
>John McCabe
>
>=====================================================================
>Any opinions expressed are mine and based on my own experience. They
>  should in no way be taken as the opinion of anyone I am currently
>     working with, or of the company I am currently working for.
>       If you have a problem with anything I say, SPEAK TO ME!
>                (remove "nospam." to reply by e-mail)
>=====================================================================
>
>






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

* Re: [Q] Operating System Command Interface
  1998-05-05  0:00 ` David C. Hoos, Sr.
@ 1998-05-05  0:00   ` John McCabe
  1998-05-05  0:00     ` Robert Dewar
  0 siblings, 1 reply; 12+ messages in thread
From: John McCabe @ 1998-05-05  0:00 UTC (permalink / raw)



>John McCabe wrote in message <6ims5j$1vo@gcsin3.geccs.gecm.com>...
>>Am I right in thinking that, as standard, Ada has no direct perating
>>system command interface akin to the C "System" call?

>You're right, but the solution is simple.  I use the following library
>function:

<..snip..>

>   pragma Import (C, Execute, "system");

<..snip..>

Thanks David.

However, I presume that this relies on the C "system" function being 
available in a linkable library.

-- 
Best Regards
John McCabe

=====================================================================
Any opinions expressed are mine and based on my own experience. They
  should in no way be taken as the opinion of anyone I am currently
     working with, or of the company I am currently working for.
                (remove "nospam." to reply by e-mail)
=====================================================================






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

* Re: [Q] Operating System Command Interface
  1998-05-05  0:00 [Q] Operating System Command Interface John McCabe
  1998-05-05  0:00 ` David C. Hoos, Sr.
  1998-05-05  0:00 ` Markus Kuhn
@ 1998-05-05  0:00 ` Do-While Jones
  1998-05-08  0:00   ` Nick Roberts
  1998-05-05  0:00 ` Stanley R. Allen
  3 siblings, 1 reply; 12+ messages in thread
From: Do-While Jones @ 1998-05-05  0:00 UTC (permalink / raw)



In article <6ims5j$1vo@gcsin3.geccs.gecm.com>,
John McCabe  <john@nospam.assen.demon.co.uk> wrote:
>Am I right in thinking that, as standard, Ada has no direct perating 
>system command interface akin to the C "System" call?

Yes, because there is no standard operating system interface.  Of course
you can always call the C "system" call from Ada, but it is just as
unpredictable in Ada as it is in C.  The Ada code to call "system" is in
the recent thread called "Program (not task) Activation". 

I took the discussion about the inconsistent behavior of C's "system" 
call to comp.lang.c, and several Windows 95-related discussion groups a
couple weeks ago.  I got only one response.  That person quoted chapter
and verse explaining why Windows 95 does not have to return an error code
if the "system" call fails.  He suggested I take the matter up with Bill
myself.  It didn't seem to bother any of the C programmers that "system" 
on Windows NT works like "system" on UNIX, but "system" on Windows 95
doesn't.  I wonder what "system" will do on Windows 98.

Do-While Jones

            +--------------------------------+
            |    Know                 Ada    |
            |        [Ada's Portrait]        |
            |    Will              Travel    |
            | wire do_while@ridgecrest.ca.us |
            +--------------------------------+





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

* Re: [Q] Operating System Command Interface
  1998-05-05  0:00 [Q] Operating System Command Interface John McCabe
  1998-05-05  0:00 ` David C. Hoos, Sr.
@ 1998-05-05  0:00 ` Markus Kuhn
  1998-05-05  0:00   ` David C. Hoos, Sr.
  1998-05-05  0:00 ` Do-While Jones
  1998-05-05  0:00 ` Stanley R. Allen
  3 siblings, 1 reply; 12+ messages in thread
From: Markus Kuhn @ 1998-05-05  0:00 UTC (permalink / raw)



John McCabe wrote:
> Am I right in thinking that, as standard, Ada has no direct perating
> system command interface akin to the C "System" call?

Look into the IEEE POSIX.5 standard, the Ada version of the Unix API.
There you'll find procedures such as

   procedure Start_Process
     (Child : out POSIX.Process_Identification.Process_ID;
      Pathname : in POSIX.Pathname;
      Template : in Process_Template;
      Arg_List : in POSIX.POSIX_String_List
               := POSIX.Empty_String_List);

in package POSIX.Process_Primitives that probably do what you want
(i.e. allow you to call "/bin/sh", etc.).

An implementation is on

  http://www.cs.fsu.edu/~baker/florist.html

Markus

-- 
Markus G. Kuhn, Security Group, Computer Lab, Cambridge University, UK
email: mkuhn at acm.org,  home page: <http://www.cl.cam.ac.uk/~mgk25/>




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

* Re: [Q] Operating System Command Interface
  1998-05-05  0:00 [Q] Operating System Command Interface John McCabe
                   ` (2 preceding siblings ...)
  1998-05-05  0:00 ` Do-While Jones
@ 1998-05-05  0:00 ` Stanley R. Allen
  1998-05-05  0:00   ` Andi Kleen
  1998-05-05  0:00   ` John McCabe
  3 siblings, 2 replies; 12+ messages in thread
From: Stanley R. Allen @ 1998-05-05  0:00 UTC (permalink / raw)



John McCabe wrote:
> 
> Am I right in thinking that, as standard, Ada has no direct perating
> system command interface akin to the C "System" call?
> 

My understanding is that the "system" call you are making
in C is actually a call to the Unix operating system; it's
not part of the C language.  The same kind of call can be made
from Ada using pragma Interface (Ada 83) or pragma Import
(Ada 95).

-- 
Stanley Allen
mailto:s_allen@hso.link.com




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

* Re: [Q] Operating System Command Interface
  1998-05-05  0:00 ` Stanley R. Allen
  1998-05-05  0:00   ` Andi Kleen
@ 1998-05-05  0:00   ` John McCabe
  1 sibling, 0 replies; 12+ messages in thread
From: John McCabe @ 1998-05-05  0:00 UTC (permalink / raw)



"Stanley R. Allen" <s_allen@hso.link.com> wrote:
>John McCabe wrote:
>> 
>> Am I right in thinking that, as standard, Ada has no direct perating
>> system command interface akin to the C "System" call?
>> 
>
>My understanding is that the "system" call you are making
>in C is actually a call to the Unix operating system; it's
>not part of the C language.

Correct me if I'm wrong, but I believe you'll find the system() function 
is included in the ANSI Standard C library definitions and is not 
dependent on Unix.

>The same kind of call can be made from Ada using pragma Interface (Ada >83) or pragma Import (Ada 95).

True, and thank you.

-- 
Best Regards
John McCabe
=====================================================================
Any opinions expressed are mine and based on my own experience. They
  should in no way be taken as the opinion of anyone I am currently
     working with, or of the company I am currently working for.
       If you have a problem with anything I say, SPEAK TO ME!
                (remove "nospam." to reply by e-mail)
=====================================================================






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

* Re: [Q] Operating System Command Interface
  1998-05-05  0:00 ` Markus Kuhn
@ 1998-05-05  0:00   ` David C. Hoos, Sr.
  0 siblings, 0 replies; 12+ messages in thread
From: David C. Hoos, Sr. @ 1998-05-05  0:00 UTC (permalink / raw)




Markus Kuhn wrote in message <354F1D90.39080B2D@cl.cam.ac.uk>...
>Look into the IEEE POSIX.5 standard, the Ada version of the Unix API.
>There you'll find procedures such as
>
>   procedure Start_Process
>     (Child : out POSIX.Process_Identification.Process_ID;
>      Pathname : in POSIX.Pathname;
>      Template : in Process_Template;
>      Arg_List : in POSIX.POSIX_String_List
>               := POSIX.Empty_String_List);
The reason I did not offer this solution is that Florist has not been ported
to all platforms, so is not as ubiquitous as the call to the "system"
library function.

David C. Hoos, Sr.







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

* Re: [Q] Operating System Command Interface
  1998-05-05  0:00 ` Stanley R. Allen
@ 1998-05-05  0:00   ` Andi Kleen
  1998-05-06  0:00     ` Markus Kuhn
  1998-05-05  0:00   ` John McCabe
  1 sibling, 1 reply; 12+ messages in thread
From: Andi Kleen @ 1998-05-05  0:00 UTC (permalink / raw)



"Stanley R. Allen" <s_allen@hso.link.com> writes:

> John McCabe wrote:
> > 
> > Am I right in thinking that, as standard, Ada has no direct perating
> > system command interface akin to the C "System" call?
> > 
> 
> My understanding is that the "system" call you are making
> in C is actually a call to the Unix operating system; it's
> not part of the C language.  The same kind of call can be made
> from Ada using pragma Interface (Ada 83) or pragma Import
> (Ada 95).

system() is part of the c library and not a system call on Unix.
It is implemented with fork() and exec(). It is part of the libc on
Unix systems and indeed part of the ISO Standard C library definition - 
so if you assume that the Ada C interface interfaces you to a full(1) 
ISO C it should be there.

Of course that doesn't mean that it is portable. What is done with
the string is implementation specified - just returning an error is legal.

-Andi

(1) Full - not subsetted. ISO C allows C without library for
embedded implementations.




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

* Re: [Q] Operating System Command Interface
  1998-05-05  0:00   ` John McCabe
@ 1998-05-05  0:00     ` Robert Dewar
  0 siblings, 0 replies; 12+ messages in thread
From: Robert Dewar @ 1998-05-05  0:00 UTC (permalink / raw)



John McCabe says

<<However, I presume that this relies on the C "system" function being
available in a linkable library.
>>

Yes, indeed, but if you used the system function from C you would be
relying on this as well!





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

* Re: [Q] Operating System Command Interface
  1998-05-05  0:00   ` Andi Kleen
@ 1998-05-06  0:00     ` Markus Kuhn
  0 siblings, 0 replies; 12+ messages in thread
From: Markus Kuhn @ 1998-05-06  0:00 UTC (permalink / raw)



Andi Kleen wrote:
> system() is part of the c library and not a system call on Unix.
[...]
> Of course that doesn't mean that it is portable. What is done with
> the string is implementation specified - just returning an error
> is legal.

Only if you restrict yourself to looking exclusively at ISO C when
designing a portable application (bad idea). The entire POSIX.2
standard is dedicated to defining the portable semantics of system().

Markus

-- 
Markus G. Kuhn, Security Group, Computer Lab, Cambridge University, UK
email: mkuhn at acm.org,  home page: <http://www.cl.cam.ac.uk/~mgk25/>




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

* Re: [Q] Operating System Command Interface
  1998-05-05  0:00 ` Do-While Jones
@ 1998-05-08  0:00   ` Nick Roberts
  0 siblings, 0 replies; 12+ messages in thread
From: Nick Roberts @ 1998-05-08  0:00 UTC (permalink / raw)



Do-While Jones wrote in message <6in63v$rd2$1@owens.ridgecrest.ca.us>...
[...] I wonder what "system" will do on Windows 98.

Crash, like everything else. ;-)

--
Nick Roberts
ThoughtWing Software, Croydon, UK
Nick.Roberts@dial.pipex.com







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

end of thread, other threads:[~1998-05-08  0:00 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-05-05  0:00 [Q] Operating System Command Interface John McCabe
1998-05-05  0:00 ` David C. Hoos, Sr.
1998-05-05  0:00   ` John McCabe
1998-05-05  0:00     ` Robert Dewar
1998-05-05  0:00 ` Markus Kuhn
1998-05-05  0:00   ` David C. Hoos, Sr.
1998-05-05  0:00 ` Do-While Jones
1998-05-08  0:00   ` Nick Roberts
1998-05-05  0:00 ` Stanley R. Allen
1998-05-05  0:00   ` Andi Kleen
1998-05-06  0:00     ` Markus Kuhn
1998-05-05  0:00   ` John McCabe

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