Historical example of code for managing job geared for dumping data to 9-track magnetic tape drive for backup

As the title mentions, this relates to code used for dumping data (3D Model IGES export file) from disk to 9-track magnetic tape, which is what was used for exporting to outside sub-contractors (toolmakers) for manufacturing of "Plastic Injection Moulds". As is seen in one of the scripts, this was used in the context of HP-UX 5.3 in 1990.

There may be those who are still working with magnetic media in this fashion, so I offer these "production" level scripts which were used in industry.

Naturally, as with any evolving industry, some of this could be steamlined/optimized with more recent equivalents. :slight_smile:




Three scripts and one C program involved:

  • mtiges.1 - Job management script
  • mtiges.dump - Data dumping script
  • mtonline - Utility to ensure tape drive online and tape data track initialized before attempting to dump
  • ck9trk.o - Program to test device readiness/online

Main program (mtiges.1):

:
# REVISIONS
#
# 90-03-27	Initial install of script
#

#  define holding area for outgoing iges files
wherefrom="/users3/iges/IGES_OUT"
whereto="/users3/iges/IGES_SENT"

log="/users2/admc/igeslogs/`date '+%y%m%d%H%M'`"
/bin/rm -f $log

clear
echo "\n
 TAPE DENSITY FORMAT\n
   1 - 1600 bpi (default & industry standard)
   2 - 6250 bpi\n
 Enter selection => \c"
read dens
if [ "$dens" = "" ]
then dens=1
fi
case $dens in
 1 ) read outputdevice <$ss/defaultiges
     density="1600 BPI"
 ;;
 2 ) read outputdevice <$ss/denseiges
     density="6250 BPI"
 ;;
 * ) echo "\n Invalid density selection" ; sleep 2 ; exit
esac

if [ "$outputdevice" = "" ]
then echo "\n DEVICE NOT DEFINED !\n    Verify presence or content of $ss/defaultiges."
     exit
fi


if [ ! -d $wherefrom ]
then echo "\n Directory $wherefrom could not be found.\n No files available."
     mkdir $wherefrom
     exit
fi

cd $wherefrom

if [ -s $ss/../ops/pending/igesfiles ]
then files="`cat $ss/../ops/pending/igesfiles | tee`"
     echo "\n Using file names identified in $ss/../ops/pending/igesfiles ."
else

avail="`ls | tee`"

if [ "$avail" = "" ]
then echo "\n No files waiting to be dumped."
     echo " Contact user to ensure data was sent to holding area.\n"
     echo "\n                         Hit return to continue ...\c"
     read a
     exit
fi

clear
echo "\n FILES IN THE IGES TAPE CREATION POOL :\n"
ll $avail

echo "\n Dump all files to tape ? [y/N] => \c"
read doall

if [ "$doall" = "" ]
then doall="n"
fi

case $doall in
  q* | Q* ) echo "\n    Tape creation job abandoned.\n"
            exit
  ;;
  y* | Y* ) echo "\n    Will do all files."
            files="$avail"
  ;;
  n* | N* ) 
            files=""
            for file in $avail
            do
               echo "\n        Dump $file to tape ? [y/n] => \c"
               read doit
               if [ "$doit" != "" ]
               then 
                 case $doit in
                   y* | Y* ) files="$files $file"
                             echo "****          Name registered for tape dump."
                   ;;
                   * ) echo "              No action taken for $file."
                   ;;
                 esac
               fi
            done
  ;;
esac

fi

if [ "$files" != "" ]
then
     echo "\n Enter banner for printout => \c"
     read title

     echo "\n Creation of IGES tape started !\n"

export files outputdevice

{    echo "\t\t\t\t`date`\n SYSTEM OF ORIGIN :\n\n
	Platform:		HP 9000 series 500
	Operating system:	HP-UX 5.3
	Device drivers:		UNIX system V compatible
	Tape drive:		HP 7978B\n\n"

     echo " IGES TAPE FORMAT :\n\n
	Tape Density:		$density
	File header record:     no
	Record length:		80
	Blocking factor:	10
        Character set:		ASCII\n\n"

     echo "\n\n\n\n\t\t\t\t`date`\n FILES CONTAINED ON THIS TAPE :\n\n"
     ls -l $files
     echo "\t\t\t\t`date`\n TAPE CREATION LOG :\n\n"

#     settings="-x -r 80 -b 10"
#     export outputdevice settings
#     igesto $files

     mtiges.dump y $files

     echo "\t\t\t\t`date`\n END OF JOB \n\n"
     clear
     echo "\n IGES job is done.\n   Log file is $log.\n" >/dev/tty
} >>$log 2>&1 
     pr $log $ss/mtiges.1 $ss/mtiges.dump | lp -dlp1 -t"$title VENDOR"
     pr $log | lp -dlp1 -t"$title LOG"
     wait
     mv $files $whereto

else echo "\n No files selected.  No action taken.\n"
fi
sleep 2

Script for dumping data to magnetic tape (mtiges.dump):

:
# REVISIONS
#
# 90-03-27	Initial install of script
#

if [ $# = 0 ]
then echo "\n Start at begining of fresh tape ? [Y/n] => \c" >$tty
     read bot
     if [ "$bot" = "" ]
     then bot="y"
     fi

     possible="`ls *.ige | tee`"
     if [ "$possible" = "" ]
     then echo "\n Directory $wherefrom was empty." >$tty
          exit
     fi

     for file in $possible
     do  echo "\n Use $file ? [y/N] => \c" >$tty
         read ans
         if [ "$ans" = "" ]
         then ans="n"
         fi

         case $ans in
           y* | Y* ) files="$files $file" >$tty
           ;;
           * ) echo "\t\t $file ignored." >$tty
           ;;
         esac
     done

     if [ "$files" = "" ]
     then echo "\n No files chosen for IGES dump." >$tty
          exit
     fi

else if [ $# = 1 ]
     then echo "\n
 usage :  mtiges.dump [y|n] iges_file_name
          y => start at begining of a new tape
          n => search of end of tape mark before adding
" >$tty
          exit
     else bot="$1"
          shift
          files="$*"
          if [ "$files" = "" ]
          then echo "\n No files identified on input line for IGES dump." >$tty
               exit
          fi
     fi
fi


case $bot in
 y* | Y* )
     echo "\n Overwriting current contents of tape.\n\t\t Initializing ..." >$tty
     touch /tmp/junk
     case $outputdevice in
      /dev/r7978iges)
        tar cvf /dev/r7978low /tmp/junk
        mt -t $outputdevice rew
        mtonline /dev/r7978low
        mt -t $outputdevice rew
        tar cvf /dev/r7978low /tmp/junk
        mtonline /dev/r7978low
       ;;
      /dev/r7978diges)
        tar cvf /dev/r7978 /tmp/junk
        mt -t $outputdevice rew
        mtonline /dev/r7978
        mt -t $outputdevice rew
        tar cvf /dev/r7978 /tmp/junk
        mtonline /dev/r7978
       ;;
     esac
     mt -t $outputdevice rew
 ;;
 * ) echo "\n Adding files to end of tape.\n\t\t Searching for end of tape ...\n" >$tty
     mtonline $outputdevice
 ;;
esac

for file in $files
do if [ -s "$file" ]
   then echo "\n`date '+%T'`\t Doing $file ..."
        echo "\n`date '+%T'`\t Doing $file ..." >$tty
        cat $file | tr -d "\012" | dd of=$outputdevice ibs=80 obs=800
   else echo "\t\t File $file not found.\n"
        echo "\t\t File $file not found.\n" >$tty
   fi
done

echo "\n`date '+%T'`\t Rewinding tape ...\n"
echo "\n`date '+%T'`\t Rewinding tape ...\n" >$tty
mt -t $outputdevice rew &

Script to ensure tape drive is ready for data transfer before proceeding (mtonline):

:
dev="$1"
val="`ck9trk.o $dev`"
while test \( "$val" = "2" \)
do echo "\007 $dev is off line. Please correct immediately."
   sleep 60
   val="`ck9trk.o $dev`"
done
set $val
echo " Device $dev is on line."
echo "$2" >&2       # file id to be used for putting the magnetic tape offline
                    # using the system subroutine "hpib_ren_ctl" man(3)

Program to test device readiness/online (ck9trk.c):

/*****************************************************************************
*
*	ck9trk()
*
*	test for online status of 9-track tape drive at device name passed.
*	version 1.0 1987/04/15		by	E. Marceau
*
*       string with the value '2' is returned if the device is not online;
*       otherwise, a message is returned as confirmation.
*
*****************************************************************************/

#define	MAXLINE	80

main(argc, argv)

int argc;
char *argv[];
{
	int len;			/* line length */
	char match[ MAXLINE ];		/* string to match */
	char line[ MAXLINE ];		/* line from standard input */
	int f1;

	if ( argc != 2 ){
		printf("Usage: t2 from\n");
		exit(1);
	}
	if (( f1 = open(argv[1], 0) ) == -1 ) {
		printf("2");
		exit(1);
	}
		printf("1 %d\n", argv[1], f1 );
}
2 Likes