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
Show All Mail Headers

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

Print Reply
Subject:
From:
"David C. Hoos" <[log in to unmask]>
Reply To:
David C. Hoos
Date:
Fri, 15 Oct 1999 17:09:44 -0500
Content-Type:
text/plain
Parts/Attachments:
text/plain (49 lines)
----- Original Message -----
From: Steven Deller <[log in to unmask]>
To: <[log in to unmask]>
Sent: Friday, October 15, 1999 11:35 AM
Subject: Re: How do I copy a file


> 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.
>
Not correct.  You issue the command string
"csh -c <single-parameter>", so the "sh" shell executes
csh with the appropriate single string parameter -- i.e.,
quoting, or escaping, or whatever to make the string
passed to csh a single parameter as far as sh is concerned.
Then csh will parse that single string.

For a concrete example "csh -c 'cp file_a file_b'"

or  "csh -c cp\ file_a\\ file_b"

I do this all the time (with tcsh), because I find the
syntax of tcsh/csh easier to rememeber than the Bourne Shell.

ATOM RSS1 RSS2