Path: utzoo!utgpu!water!watmath!clyde!att!att-ih!ihnp4!ucbvax!CLVMS.CLARKSON.EDU!ABSTINE From: ABSTINE@CLVMS.CLARKSON.EDU (Art Stine - Network Engineer) Newsgroups: comp.os.vms Subject: anyone have any clues why this doesn't work Message-ID: <8804260836.AA24421@ucbvax.Berkeley.EDU> Date: 20 Apr 88 22:14:00 GMT Sender: usenet@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 80 Folks: I am trying to whip up a quick and dirty program which will emulate the Unix tail program, ie, read the last n lines of a file. I wrote up the following code, which seems like it should work, but it doesn't seem to position the file at EOF. any clues what i'm doing wrong? thanks art stine network engineer clarkson u character*80 inline external open_eof integer*4 for_len open(1, name='SYS$MANAGER:LPR_SERVER.LOG', type='OLD', & useropen=open_eof) print 100 100 format('$Number of records from end? ') accept*,nback read(1,'(a)', end=5) inline 5 do i = 1, nback backspace 1 enddo 10 read(1,'(a)', end=99) inline print *, inline goto 10 99 close(unit=1) call exit end INTEGER FUNCTION open_eof(fab, rab, lun) IMPLICIT NONE ! ! Include definition files ! INCLUDE '($SYSSRVNAM)' INCLUDE '($FABDEF)' INCLUDE '($RABDEF)' ! ! Parameter declarations ! RECORD /FABDEF/ fab RECORD /RABDEF/ rab INTEGER*4 lun ! ! Local storage ! INTEGER*4 status ! ! open file ! status = sys$open(fab) ! ! if opened ok, then connect stream to file ! IF (status) THEN ! ! set open at EOF flag ! rab.rab$l_rop = rab.rab$l_rop .OR. rab$m_eof status = sys$connect(rab) ENDIF open_eof = status return end