script providing input to application prompts

Hi!

I want to write a script that will create an archive (via tar) that will restrict the size of the tar file. The size can be constrained using the keyword 'k' and providing the size restriction. The problem is that the script needs to know (detect) when the tar command prompts the user (which will be this script) so that the script can copy the tar file to a temporary file (like tarFileName.1) and then return control back to the tar command to create the next volume.

(hope you could follow that logic)

My problem is I know of no mechanism in scripting in unix that allows for this kind of command flow control. Does it exist? Can anyone suggest a method I can use for this? (interrupt handlers; subs; ....)

tia,
mitch

ps the reason for needing to limit the size is to allow a customer to ftp some huge subdirectories (>10Gb) in bitesize pieces. The script will first gzip all the files, then archive them into volumes of, say, 100Mb in size. But the tar command prompts the user to change the archive media and hit RETURN to continue. The operator needs to copy the tar file to some other file, then hit return for this method to work.

You can do it in much simpler way in three steps:

  1. Create the full archive file xxx.tar.gz or xxx.tar.

  2. split -b <size> xxx.tar.gz
    where <size> is the size of single piece.

  3. mv xaa xxx_1.tar.gz
    mv xab xxx_2.tar.gz
    .................................

In order to reassable the pieces togather again

cat xxx_1.tar.gz xxx_2.tar.gz ..... xxx_N.tar.gz > myarchive.tar.gz

ya gotta like simple - thanks

mitch