All pastes #2057562 Raw Edit

clueless

public text v1 · immutable
#2057562 ·published 2011-05-12 19:20 UTC
rendered paste body
##	This shell script will "fill" a floppy with files from#	another floppy until the destination floppy is full.#	then it will ask for a second destination floppy and #	continue to fill that floppy until it is full as well.#	This process will continue until the all the file have been copied to#	the destination floppies or the user asks to quit the procedure###	functions used in this script :#function gettxt {read text?"Please enter the $*  "echo $text;}typeset -xf gettxtfunction getyesno {noans=twhile [ $noans = t ] ; do	read text?"$* ( Must use y for yes, n for no )"	if [ "x$text" = xy ] ; then		echo y		noans=f	elif [ "x$text" = xn ] ; then		echo n		noans=f	fidone;}typeset -xf getyesnofunction verifytxt {desc=$1name=$2read ans?"$desc : $nameCorrections ? ( enter for none ) >> "if [ "x$ans" != x ] ; then	ans=`verifytxt "$desc" "$ans"`	echo $anselse	echo $namefi;}typeset -xf verifytxtif [ "x$DEBUG" = "xT" ] ; then	set -vxfi##	Begin main section of script###	get the name of the source directory/floppyread src?"Fill FROM what floppy drive/directory ?  "src=`verifytxt "Verify: Fill FROM what floppy drive/directory ? " $src`echo "\n\n"##	get the name of the destination directory/floppyread target?"Fill TO what floppy drive ?  "target=`verifytxt "Verify: Fill TO what floppy drive ?  " $target`echo "\n\n"##	get the size of the destination directory/floppyread ans?"What is the size of the floppy drive ( 1440 kbytes is default)"ans=`verifytxt "Verify: size of the floppy drive " $ans`if [ "x$ans" = x ] ; then	ans=1440000fitypeset -i size=$ansif [ $size -le 0 ] ; then	 size=1440000 fiprint "size is $size"##	get the list and sizes of file from the source#typeset -i total=`ls -l $src | egrep -v '^d' | egrep -v "total [0-9][0-9]" | awk '{sum=sum+$5} END{print sum}'`print "the total space needed is $total."typeset -i howmanydisks=0typeset -i sum=0typeset -i position=0typeset -i rem=0typeset -i i=0typeset -i newroomleft=0typeset -i roomleft=$size(( howmanydisks= $total / $size ))(( rem= $howmanydisks * $size ))if [ ! $rem -eq $total ] ; then	(( howmanydisks= $howmanydisks + 1 ))fiprint "$howmanydisks disks will be needed."roomleft=$sizefor file in `ls $src` ; do	if [ ! -d $file ] ; then 		print "preparing to add file $file."		fsize=`ls -l $file | awk '{print $5}'`		if [ $fsize -lt $size ] ; then			(( newroomleft= $roomleft - $fsize ))			echo There is $roomleft space left on the current disk			echo File $file needs $fsize space.			echo there will be $newroomleft after copying $file to the current disk			if [ $newroomleft -lt 1 ] ; then				read ans?"Not enough room on this disk, place next disk in drive and press enter."				echo setting space left on new disk				(( roomleft= $size - $fsize ))			else 				echo setting space left on current disk				(( roomleft= $roomleft - $fsize ))			fi			echo cp $file ${target}/.			cp $file ${target}/.		else			echo "Skipping $file becasuse it is too large to fit on a floppy"		fi	else		echo "Skipping $file because it is a directory."	fidone