#!/bin/bash
#
#   tape_eject.sh
# a simple script that uses the web interface to eject a tape
# the only parameter required is which slot you want ejected
# written for the Quantum SuperLoader 3, model # L700
#
# Todd Rowe, toddrowe@gmail.com, 3/24/2009

# defaults
FROM="1"                # the only input: 1-8 = left magazine, 9-16 = right magazine
TO="18"                 # 17=drive, 18=mailslot, 19=picker
IP="192.168.20.128"     # from the quick start guide, adjust this if you changed it
USER="guest"            # from the quick start guide, adjust this if you changed it
PASS="guest"            # from the quick start guide, adjust this if you changed it

if [ -z "$1" ] ; then
    echo "   tape_eject.sh - because mtx can't see my mailslot"
    echo "   Usage: tape_eject.sh <from_slot_#>"
    echo "          other variables may need to be configured for your setup"
    exit 0
  else
    FROM=$1
fi

CMDSTR="wget --quiet --referer=http://$IP/commands.html --user=$USER --password=$PASS --post-data 'from=$FROM&to=$TO&submit=submit' http://$IP/move.cgi -O /dev/null"

echo "Sending command..."

$CMDSTR
