Fri, 15 Oct 1999 17:09:44 -0500
----- 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]]
> > 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"
> > >
> > > 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
> > > format ... For your application, just make a simple pragma interface C
> > > 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.