#!/usr/bin/expect -f match_max -d 10000000 set tape /dev/st0 send_user "# Enabling Hardware Compression\n" system mt -f $tape datcompression 2 send_user "# Rewinding tape\n" system mt -f $tape rewind send_user "# Starting Backup\n" sleep 5 spawn -noecho tar Mcf $tape /fs/files expect { -re "Prepare volume #([0-9]+) for .+ and hit return:" { send_user "Changing to volume #$expect_out(1,string):" system mt -f $tape offline sleep 180 send "\r" send_user " done.\n" exp_continue } eof { send_user "# Backup has completed\n" exit } -re ".*" { sleep 1 exp_continue } }