#!/bin/sh #=========================================================================================== # R e a d S E G B f i l e s f r o m t a p e # # Syntax: # read-SEGB-from-9tr-tape.sh reel_number shots # # Description: # Reads 9-track 1/2" tape from Qualstar Mod 3416S drive, with SCSI interface. # First creates directory named reel_number. Then extracts shot files from # tape and put these into individual files, numbered in sequence. # Set block size of tape to "0", which really means "variable" # mt -f /dev/stx setblk 0 # Check with mt -f /dev/stx status # # # Assumes: # Tapes written on DFS-V seismic recorder, in SEG-B format. # # Tips: # From the command line you can determine largest block size and set # 'block_size' parameter accordingly. Start with this command (assuming # the drive is /dev/nst0): # dd if=/dev/nst0 of=1.segb ibs=2M count=1 # Do this repeatedly, increasing output file number ('of') as you go. The record # structure soon appears - you can e.g. have 1 short header block, then a large # data block, followed by an empty block; these three parts constitute a shot record. # Initially, set variable block size by typing: # mt -f /dev/st0 setblk 0 # # Credits: # Bent Ole Ruud # University of Bergen (UoB) # Dept. of Earth Science (DES) # Norway # # Ole Meyer, UoB, DES # 22. November 2005 #============================================================================================= #------- Missing command line arguments? if [ $# != "2" ]; then echo "Error: No command line arguments" exit 1 fi #------- Constants: tape=/dev/nst0 # Must be non-rewinding (the 'n' in 'nst0' means non-rewinding). block_size=1M # You must experiment with various blocksizes to have room for the largest record number_of_records=3 # Each shotfile consists of that many records first=1 last=$2 # Number of shots to extract given as command line parameter file_extension=segb format=%04d # Filename format, e.g. 0=zeros first, 4=number of digits, d=decimal number echo "Reel number: $1" echo "Is this correct [y/n]?" read answer if [ $answer = "y" -o $answer = "Y" ] then echo "OK, creating directory reel-$1" mkdir reel-$1 cd reel-$1 echo "Rewinding tape ..." mt -f $tape rewind echo "Copying shot files ...." file_no=$first of_name=`printf "$format.$file_extension" $file_no` while [ $file_no -le $last ]; do echo "Writing file $of_name" dd if=$tape of=$of_name ibs=$block_size count=$number_of_records file_no=`expr $file_no + 1` of_name=`printf "$format.$file_extension" $file_no` done echo "Rewinding tape ..." mt -f $tape rewind echo "Done!" else echo "Correct mistakes" fi exit