home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / fortran / 3318 < prev    next >
Encoding:
Internet Message Format  |  1992-08-31  |  2.6 KB

  1. Path: sparky!uunet!sun-barr!news2me.ebay.sun.com!exodus.Eng.Sun.COM!appserv.Eng.Sun.COM!appserv!khb
  2. From: khb@chiba.Eng.Sun.COM (Keith Bierman fpgroup)
  3. Newsgroups: comp.lang.fortran
  4. Subject: Re: copying files in FORTRAN on using Sun Fortran
  5. Date: 31 Aug 92 19:02:10
  6. Organization: Sun MegaSystems
  7. Lines: 74
  8. Message-ID: <KHB.92Aug31190210@chiba.Eng.Sun.COM>
  9. References: <1992Aug28.195415.27820@ctr.columbia.edu> <1992Aug29.062208.26841@chpc.utexas.edu>
  10. NNTP-Posting-Host: chiba
  11. In-reply-to: aswx266@chpc.utexas.edu's message of Sat, 29 Aug 92 06:22:08 GMT
  12.  
  13.  
  14. In article <1992Aug29.062208.26841@chpc.utexas.edu> aswx266@chpc.utexas.edu (Michael Lemke) writes:
  15.  
  16.  
  17.  
  18.    Although I don't know where you can find it (presumably man 3F intro 
  19.    should get you started) it is easy as pie:
  20.  
  21.        call system( 'cp file1 file2' )
  22.  
  23.  
  24. The approriate syntax (as per the Fortran manuals) is
  25.  
  26.     istat=system(command-string)
  27.  
  28. The man page (3f) is as follows:
  29.  
  30.  
  31. SYSTEM(3F)          FORTRAN LIBRARY ROUTINES           SYSTEM(3F)
  32.  
  33. NAME
  34.      system - execute a SunOS command
  35.  
  36. SYNOPSIS
  37.      integer function system (string)
  38.      character*(*) string
  39.  
  40. DESCRIPTION
  41.      The function system gives string to your shell as input,  as
  42.      if  the string had been typed as a command.  If the environ-
  43.      ment variable SHELL is found, its value will be used as  the
  44.      command interpreter (shell); otherwise sh(1) is used.
  45.  
  46.      The current process waits until the command terminates.  The
  47.      returned  value  will  be the exit status of the shell.  See
  48.      wait(2) for an explanation of this value.
  49.  
  50.      Note that historically cc and f77 developed  with  different
  51.      assumptions:  if  cc  calls  system  the shell is always the
  52.      Bourne shell, whereas if f77 calls system which  shell  gets
  53.      called depends on the environment variable SHELL .
  54.  
  55.      WARNING: System flushes all open files.
  56.      For output files, the buffer is flushed to the actual file.
  57.      For input files, the position of the pointer  is  unpredict-
  58.      able.
  59.  
  60. FILES
  61.      libF77.a
  62.  
  63. SEE ALSO
  64.      execve(2), wait(2), system(3)
  65.  
  66. BUGS
  67. String can not be longer than 1024 characters.
  68.  
  69. So a working sample program is:
  70.  
  71.       PROGRAM COPYFILE
  72.       CHARACTER*10 AFILE,BFILE
  73.       INTEGER SYSTEM
  74.  
  75.       AFILE='bork.f'
  76.       BFILE='bork2.F'
  77.  
  78.       I= SYSTEM('cp '//AFILE//BFILE)
  79.       IF (I .NE. 0) PRINT*,' SYSTEM COMMAND RETURNED ',I
  80.       END
  81. --
  82. ----------------------------------------------------------------
  83. Keith H. Bierman    keith.bierman@Sun.COM| khb@chiba.Eng.Sun.COM
  84. SunPro 2550 Garcia MTV 12-33             | (415 336 2648) fax 964 0946
  85. Mountain View, CA 94043  <speaking for myself, not Sun*> Copyright 1992
  86.  
  87.