Automating executing commands on multiple tapes and changing (loading) them

The thing that we need to be able to do is:

  • Scanning tapes from failed backup jobs with bscan (a bacula command)
  • loading the next tape with the mtx command

Bscan does unload tapes but does not load them.

Bscan comes with this message when it's done with a tape:

Mount Volume "XO7563L3" on device "Tape1" (/dev/nst0) and press return when ready:

The script doesn't have to be fancy like determine in what slot the volume is. It would be enough just loading the tapes from let's say slot 10 to 24 and we need to make sure they are loaded in the right order into the tape library.

The thing that we ran into is that when the above message appears it normally should input the answer but in this case it should run another command first and then input the answer.

Is Expect the program for the job and how to do it?

Thanks...