TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy

TEAM-ADA@LISTSERV.ACM.ORG

Options: Use Forum View

Use Monospaced Font
Show Text Part by Default
Condense Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Sender:
"Team Ada: Ada Advocacy Issues (83 & 95)" <[log in to unmask]>
X-To:
Mike Brenner <[log in to unmask]>
Date:
Fri, 15 Oct 1999 12:35:09 -0400
Reply-To:
Steven Deller <[log in to unmask]>
Subject:
MIME-Version:
1.0
Content-Transfer-Encoding:
7bit
Content-Type:
text/plain; charset="us-ascii"
From:
Steven Deller <[log in to unmask]>
Parts/Attachments:
text/plain (103 lines)
On Friday, October 15, 1999 10:33 AM, Mike Brenner [SMTP:[log in to unmask]]
wrote:
> Wretling Urban> I want to execute the cp command on unix to copy a
> file ...
>
> Steve Deller > POSIX 1003.1a (I think that is the right update
> letter) defines a C call for
> > what you want, namely:   int system(const char *command)
> > That invokes the system standard "sh" shell to run the "command"
string...
> >
> > POSIX 1003.5 and 1003.5(b) (the latest I believe) were done against
> > earlier
> > versions of 1003.1 and thus do not have the system call in a standard Ada
> > format ... For your application, just make a simple pragma interface C to
> > the system
> > call.  If you need more explanation than that, let me know.
>
> Doing system calls in an operating system manner has always been
> problematical for me. I would appreciate pointers to further
> explanations of the following:
>
>   (a) What if you want the csh instead of the sh?

Not possible through POSIX.


>   (b) Is there a chart where to download or purchase a Posix binding
> for each Ada compiler?

Depends on the vendor.  Speaking for Rational, it is part of Apex -- if you
have a license for Apex, then you have access to the POSIX subsystem with its
implementation.  I believe this is true of most Ada vendors, but do not want
to speak for them.

>   (c) Is there a chart that shows which calls are compatible between
> Linux and NT 4.0 Service Pack 5?

This has nothing to do with POSIX, and arguably has nothing to do with a
software API.  POSIX is POSIX.  Either a system is compliant or it is not.
 If it is not, then you'll have to read that system's manual to find out what
they might do that is "POSIX-like".

>   (d) Is there a chart that shows which calls are compatible between
> Linux and Solaris 2.6?

POSIX defines a portable API.  If a system is compliant with some POSIX
standard then you can use all POSIX functions.  See the POSIX manuals for the
definition of compliance.  But nothing comes free, and you MUST be aware of
any possible implementation dependencies.  Further, you must find out WHICH
POSIX bindings are supported -- there are over 15 POSIX standards.  A system
may be POSIX 1003.1 compliant, but not 1003.2 compliant.  For Ada bindings,
there are only 2 bindings that are standard, which only cover a portion of
the C interfaces that have POSIX standards.

By and large, POSIX calls (Ada or C) are very portable between compliant
systems.

>   (e) Is there documentation showing (in the example of the cp
> command) the difference between various possible error conditions
> such as (1) the cp command does not exist, (2) the cp command was
> available but privacy controls prevent executing it, (3) the cp
> command failed due to problems with the source file (e.g. file not
> found), (4) the cp command failed due to problems with the target
> file (e.g. disk full).

IMHO RTFM.

In the manual for the system() interface, it describes in gory detail all the
possible error conditions from the call.  You have both the return value and
ERRNO for distinguishing error conditions.

The manual tells you what error conditions occur.  If "cp" does not exist for
you (a combination of your case (1) and (2)), then the "sh" error return will
tell you that.   If "cp" ran, but failed then the sh return value is greater
than zero -- with POSIX I do not believe there is any further distinction
with the error value so your cases (3) and (4) cannot be *portably*
distinguished using the "cp" command.  You may find fault with POSIX for
this, but since "cp" can do many things, including copying of hierarchies, it
seems to me that there are just too many failure cases to try to distinguish
them all.

If you want to distinguish error cases in more detail, I suggest you write
your own file copy using POSIX File manipulation primitives.

Your case (2) is interesting but ill-defined.  If you want to know if it
exists on the disk, but isn't in your PATH, then some combination of
"whereis" and "find" commands might be in order.  If you want to know if some
file named "cp" is somewhere on your PATH that is executable by someone but
not by you, then you would have to use "find" or "ls" commands.  If you want
to know if it is visible and executable by someone else, but not you, then
you would have to "become" that other person in order to see "cp".
  Circumventing privacy controls to see a file that someone else can use
would be at odds with the intention of privacy controls.

Regards,
Steve

Steven Deller, Apex Ada Marketing
[log in to unmask], (410) 757 6924
Rational Software Corporation, http://www.rational.com
For user email groups, check  http://www.rational.com/support/newsgroup

ATOM RSS1 RSS2