	PRO mtcom, unit, rewind=rewind, skpf=skpf, skpr = skpr
;	-------------------------------------------------------------
;+
;	NAME:
;		mtcom
;	PURPOSE:
;		Reposition tape unit via either rewind or skip 
;		forward "skpf" files or "skpr" records.
;	Calling SEQ:
;		THIS IS NOT FOR THE AVERAGE USER -- USE MT.PRO
;	HISTORY:
;		written, 1991, gal
;		14-Feb-91, gal & Andy Phillips, added a patch for 
;		OSF/1-IDL problem of getting Interrupted System Call
;		after rewind command.
;        17-Feb-94, JRL, Fixed a typo (N_IOERROR ==> ON_IOERROR)
;         7-Jul-94, SLF, suppress annoying 'error' messages which always show up
;
;-
;	-------------------------------------------------------------

	mtcommand = ' '			;init command	
	info = Fstat(unit)		;get the device name 
	dev  = info.name			

	IF (!version.OS ne 'IRIX') THEN BEGIN	;deal with diff machines
	  sw = '-f '			;switch for sun & ultrix
	ENDIF ELSE BEGIN
	  sw = '-t '			;switch for SGI
	ENDELSE

	IF (KEYWORD_SET(rewind)) THEN BEGIN
	  mtcommand = 'mt '+ sw + dev + ' rewind'	;rewind command
	ENDIF

	IF (KEYWORD_SET(skpf)) THEN BEGIN
	  IF (skpf ne 0) THEN BEGIN	
;	    print,'**** skip forward files= ', skpf	
	    mtcommand = 'mt '+ sw + dev +' fsf '+ $
		STRTRIM(string(skpf), 2)
	  ENDIF				;skip not equal 0
	ENDIF

	IF (KEYWORD_SET(skpr)) THEN BEGIN
	  IF (skpr ne 0) THEN BEGIN
;	    print,'**** skipping forward records= ', skpr
	    mtcommand = 'mt '+ sw + dev +' fsr '+ $ 
		STRTRIM(STRING(skpr), 2)
	  ENDIF
	ENDIF

;	print, '**** mt command: ', mtcommand
	IF (mtcommand ne ' ') THEN BEGIN
	    close, unit			;release dev to shell
	    SPAWN, mtcommand 		;do the command
	    ON_IOERROR, open_error	;set error trap
	    openr, unit, dev		;re-connect to device
            GOTO, norm_open
open_error: ON_IOERROR, NULL             ;cancel error trap
;           Print,'Device Problems--Trying AGAIN to RE-OPEN device '	;, p1 (JRL commented out)
            wait, 2                     ;wait a second and
	    openr, unit, dev		;re-connect to device
norm_open:  ON_IOERROR, NULL		;cancel error trap
	ENDIF

	RETURN
	END
