home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!sun-barr!news2me.ebay.sun.com!exodus.Eng.Sun.COM!appserv.Eng.Sun.COM!appserv!khb
- From: khb@chiba.Eng.Sun.COM (Keith Bierman fpgroup)
- Newsgroups: comp.lang.fortran
- Subject: Re: copying files in FORTRAN on using Sun Fortran
- Date: 31 Aug 92 19:02:10
- Organization: Sun MegaSystems
- Lines: 74
- Message-ID: <KHB.92Aug31190210@chiba.Eng.Sun.COM>
- References: <1992Aug28.195415.27820@ctr.columbia.edu> <1992Aug29.062208.26841@chpc.utexas.edu>
- NNTP-Posting-Host: chiba
- In-reply-to: aswx266@chpc.utexas.edu's message of Sat, 29 Aug 92 06:22:08 GMT
-
-
- In article <1992Aug29.062208.26841@chpc.utexas.edu> aswx266@chpc.utexas.edu (Michael Lemke) writes:
-
-
-
- Although I don't know where you can find it (presumably man 3F intro
- should get you started) it is easy as pie:
-
- call system( 'cp file1 file2' )
-
-
- The approriate syntax (as per the Fortran manuals) is
-
- istat=system(command-string)
-
- The man page (3f) is as follows:
-
-
- SYSTEM(3F) FORTRAN LIBRARY ROUTINES SYSTEM(3F)
-
- NAME
- system - execute a SunOS command
-
- SYNOPSIS
- integer function system (string)
- character*(*) string
-
- DESCRIPTION
- The function system gives string to your shell as input, as
- if the string had been typed as a command. If the environ-
- ment variable SHELL is found, its value will be used as the
- command interpreter (shell); otherwise sh(1) is used.
-
- The current process waits until the command terminates. The
- returned value will be the exit status of the shell. See
- wait(2) for an explanation of this value.
-
- Note that historically cc and f77 developed with different
- assumptions: if cc calls system the shell is always the
- Bourne shell, whereas if f77 calls system which shell gets
- called depends on the environment variable SHELL .
-
- WARNING: System flushes all open files.
- For output files, the buffer is flushed to the actual file.
- For input files, the position of the pointer is unpredict-
- able.
-
- FILES
- libF77.a
-
- SEE ALSO
- execve(2), wait(2), system(3)
-
- BUGS
- String can not be longer than 1024 characters.
-
- So a working sample program is:
-
- PROGRAM COPYFILE
- CHARACTER*10 AFILE,BFILE
- INTEGER SYSTEM
-
- AFILE='bork.f'
- BFILE='bork2.F'
-
- I= SYSTEM('cp '//AFILE//BFILE)
- IF (I .NE. 0) PRINT*,' SYSTEM COMMAND RETURNED ',I
- END
- --
- ----------------------------------------------------------------
- Keith H. Bierman keith.bierman@Sun.COM| khb@chiba.Eng.Sun.COM
- SunPro 2550 Garcia MTV 12-33 | (415 336 2648) fax 964 0946
- Mountain View, CA 94043 <speaking for myself, not Sun*> Copyright 1992
-
-