| 1 |
<HTML> |
| 2 |
<HEAD> |
| 3 |
<TITLE>TapeChanger::MTX - use 'mtx' to manipulate a tape library</TITLE> |
| 4 |
<LINK REV="made" HREF="mailto:none"> |
| 5 |
</HEAD> |
| 6 |
|
| 7 |
<BODY> |
| 8 |
|
| 9 |
<A NAME="__index__"></A> |
| 10 |
<!-- INDEX BEGIN --> |
| 11 |
|
| 12 |
<UL> |
| 13 |
|
| 14 |
<LI><A HREF="#name">NAME</A></LI> |
| 15 |
<LI><A HREF="#synopsis">SYNOPSIS</A></LI> |
| 16 |
<LI><A HREF="#description">DESCRIPTION</A></LI> |
| 17 |
<LI><A HREF="#variables">VARIABLES</A></LI> |
| 18 |
<LI><A HREF="#usage">USAGE</A></LI> |
| 19 |
<LI><A HREF="#notes">NOTES</A></LI> |
| 20 |
<LI><A HREF="#requirements">REQUIREMENTS</A></LI> |
| 21 |
<LI><A HREF="#todo">TODO</A></LI> |
| 22 |
<LI><A HREF="#see also">SEE ALSO</A></LI> |
| 23 |
<LI><A HREF="#author">AUTHOR</A></LI> |
| 24 |
<LI><A HREF="#copyright">COPYRIGHT</A></LI> |
| 25 |
</UL> |
| 26 |
<!-- INDEX END --> |
| 27 |
|
| 28 |
<HR> |
| 29 |
<P> |
| 30 |
<H1><A NAME="name">NAME</A></H1> |
| 31 |
<P>TapeChanger::MTX - use 'mtx' to manipulate a tape library</P> |
| 32 |
<P> |
| 33 |
<HR> |
| 34 |
<H1><A NAME="synopsis">SYNOPSIS</A></H1> |
| 35 |
<PRE> |
| 36 |
use TapeChanger::MTX;</PRE> |
| 37 |
<PRE> |
| 38 |
my $loaded = TapeChanger::MTX->loadedtape; |
| 39 |
print "Currently loaded: $loaded\n" if ($loaded);</PRE> |
| 40 |
<PRE> |
| 41 |
TapeChanger::MTX->loadtape('next'); |
| 42 |
my $nowloaded = TapeChanger::MTX->loadedtape; |
| 43 |
print "Currently loaded: $nowloaded\n" if ($nowloaded); |
| 44 |
</PRE> |
| 45 |
<PRE> |
| 46 |
|
| 47 |
See below for more available functions.</PRE> |
| 48 |
<P> |
| 49 |
<HR> |
| 50 |
<H1><A NAME="description">DESCRIPTION</A></H1> |
| 51 |
<P>TapeChanger::MTX is a module to manipulate a tape library using the 'mtx' |
| 52 |
tape library program. It is meant to work with a simple shell/perl script |
| 53 |
to load and unload tapes as appropriate, and to provide a interface for |
| 54 |
more complicated programs to do the same. The below functions and |
| 55 |
variables should do as good a job as explaining this as anything.</P> |
| 56 |
<P> |
| 57 |
<HR> |
| 58 |
<H1><A NAME="variables">VARIABLES</A></H1> |
| 59 |
<DL> |
| 60 |
<DT><STRONG><A NAME="item_%24TapeChanger%3A%3AMTX%3A%3AMT_%3Ditem_%24TapeCha">$TapeChanger::MTX::MT |
| 61 |
=item $TapeChanger::MTX::MTX</A></STRONG><BR> |
| 62 |
<DD> |
| 63 |
What is the location of the 'mt' and 'mtx' binaries? Can be set with |
| 64 |
'$MT' and '$MTX' in ~/.mtxrc, or defaults to '/usr/sbin/mt' and |
| 65 |
'/usr/local/sbin/mtx'. |
| 66 |
<P></P> |
| 67 |
<DT><STRONG><A NAME="item_%24TapeChanger%3A%3AMTX%3A%3ADRIVE">$TapeChanger::MTX::DRIVE</A></STRONG><BR> |
| 68 |
<DD> |
| 69 |
<DT><STRONG><A NAME="item_%24TapeChanger%3A%3AMTX%3A%3ACONTROL">$TapeChanger::MTX::CONTROL</A></STRONG><BR> |
| 70 |
<DD> |
| 71 |
What are the names of the tape (DRIVE) and changer (CONTROL) device |
| 72 |
nodes? Can be set with $DRIVE or $CONTROL in ~/.mtxrc, or default to |
| 73 |
'/dev/rmt/0' and '/dev/changer' respectively. |
| 74 |
<P></P> |
| 75 |
<DT><STRONG><A NAME="item_%24TapeChanger%3A%3AMTX%3A%3AEJECT">$TapeChanger::MTX::EJECT</A></STRONG><BR> |
| 76 |
<DD> |
| 77 |
Does the tape drive have to eject the tape before the changer retrieves |
| 78 |
it? It's okay to say 'yes' if it's not necessary, in most cases. Can be |
| 79 |
set with $EJECT in ~/.mtxrc, or defaults to '1'. |
| 80 |
<P></P> |
| 81 |
<DT><STRONG><A NAME="item_%24TapeChanger%3A%3AMTX%3A%3AREADY_TIME">$TapeChanger::MTX::READY_TIME</A></STRONG><BR> |
| 82 |
<DD> |
| 83 |
How long should we wait to see if the drive is ready, in seconds, after |
| 84 |
mounting a volume? Can be set with $READY_TIME in ~/.mtxrc, or defaults |
| 85 |
to 60. |
| 86 |
<P></P> |
| 87 |
<DT><STRONG><A NAME="item_%24TapeChanger%3A%3AMTX%3A%3ADEBUG">$TapeChanger::MTX::DEBUG</A></STRONG><BR> |
| 88 |
<DD> |
| 89 |
Print debugging information? Set to '0' for normal verbosity, '1' for |
| 90 |
debugging information, or '-1' for 'quiet mode' (be as quiet as possible). |
| 91 |
<P></P></DL> |
| 92 |
<P> |
| 93 |
<HR> |
| 94 |
<H1><A NAME="usage">USAGE</A></H1> |
| 95 |
<P>This module uses the following functions:</P> |
| 96 |
<DL> |
| 97 |
<DT><STRONG><A NAME="item_tape_cmd">tape_cmd ( COMMAND )</A></STRONG><BR> |
| 98 |
<DD> |
| 99 |
<DT><STRONG><A NAME="item_mt_cmd">mt_cmd ( COMMAND )</A></STRONG><BR> |
| 100 |
<DD> |
| 101 |
Runs 'mtx' and 'mt' as appropriate. <CODE>COMMAND</CODE> is the command you're |
| 102 |
trying to send to them. Uses 'warn()' to print the commands to the screen |
| 103 |
if $TapeChanger::MTX::DEBUG is set. |
| 104 |
<P></P> |
| 105 |
<DT><STRONG><A NAME="item_numdrives">numdrives ()</A></STRONG><BR> |
| 106 |
<DD> |
| 107 |
<DT><STRONG><A NAME="item_numslots">numslots ()</A></STRONG><BR> |
| 108 |
<DD> |
| 109 |
<DT><STRONG><A NAME="item_loadedtape">loadedtape ()</A></STRONG><BR> |
| 110 |
<DD> |
| 111 |
Returns the number of drives, number of slots, and currently loaded tape |
| 112 |
values, respectively, by parsing <STRONG>tape_cmd('status')</STRONG>. |
| 113 |
<P></P> |
| 114 |
<DT><STRONG><A NAME="item_loadtape">loadtape ( SLOT [, DRIVE] )</A></STRONG><BR> |
| 115 |
<DD> |
| 116 |
Loads a tape into the tape changer, and waits until the drive is again |
| 117 |
ready to be written to. <CODE>SLOT</CODE> can be any of the following (with the |
| 118 |
relevant function indicated): |
| 119 |
<PRE> |
| 120 |
current C<loadedtape()> |
| 121 |
prev C<loadprevtape()> |
| 122 |
next C<loadnexttape()> |
| 123 |
first C<loadfirsttape()> |
| 124 |
last C<loadlasttape()> |
| 125 |
0 C<_ejectdrive()> |
| 126 |
1..99 Loads the specified tape number, ejecting whatever is |
| 127 |
currently in the drive.</PRE> |
| 128 |
<P><CODE>DRIVE</CODE> is the drive to load, and defaults to 0. Returns 0 if |
| 129 |
successful, an error string otherwise.</P> |
| 130 |
<P></P> |
| 131 |
<DT><STRONG><A NAME="item_loadnexttape">loadnexttape ()</A></STRONG><BR> |
| 132 |
<DD> |
| 133 |
<DT><STRONG><A NAME="item_loadprevtape">loadprevtape ()</A></STRONG><BR> |
| 134 |
<DD> |
| 135 |
<DT><STRONG><A NAME="item_loadfirsttape">loadfirsttape ()</A></STRONG><BR> |
| 136 |
<DD> |
| 137 |
<DT><STRONG><A NAME="item_loadlasttape">loadlasttape ()</A></STRONG><BR> |
| 138 |
<DD> |
| 139 |
Loads the next, previous, first, and last tapes in the changer |
| 140 |
respectively. Use <STRONG>tape_cmd('next')</STRONG>, <STRONG>tape_cmd('previous')</STRONG>, |
| 141 |
<STRONG>tape_cmd('first')</STRONG>, and <STRONG>tape_cmd('last')</STRONG>, respectively. |
| 142 |
<P></P> |
| 143 |
<DT><STRONG><A NAME="item_ejecttape">ejecttape ()</A></STRONG><BR> |
| 144 |
<DD> |
| 145 |
Ejects the tape, by first ejecting the tape from the drive |
| 146 |
(<STRONG>mt_cmd(rewind)</STRONG> then <STRONG>mt_cmd(offline)</STRONG>) and then returning it to its |
| 147 |
slot (<STRONG>tape_cmd(unload)</STRONG>). Returns 1 if successful, 0 otherwise. |
| 148 |
<P></P> |
| 149 |
<DT><STRONG><A NAME="item_resetchanger">resetchanger ()</A></STRONG><BR> |
| 150 |
<DD> |
| 151 |
Resets the changer, ejecting the tape and loading the first one from the |
| 152 |
changer. |
| 153 |
<P></P> |
| 154 |
<DT><STRONG><A NAME="item_checkdrive">checkdrive ()</A></STRONG><BR> |
| 155 |
<DD> |
| 156 |
Checks to see if the drive is ready or not, by waiting for up to |
| 157 |
$TapeChanger::MTX::READY_TIME seconds to see if it can get status |
| 158 |
information using <STRONG>mt_cmd(status)</STRONG>. Returns 1 if so, 0 otherwise. |
| 159 |
<P></P> |
| 160 |
<DT><STRONG><A NAME="item_reportstatus">reportstatus</A></STRONG><BR> |
| 161 |
<DD> |
| 162 |
Returns a string containing the loaded tape and the drive that it's |
| 163 |
mounted on. |
| 164 |
<P></P> |
| 165 |
<DT><STRONG><A NAME="item_cannot_run">cannot_run ()</A></STRONG><BR> |
| 166 |
<DD> |
| 167 |
Does some quick checks to see if you're actually capable of using this |
| 168 |
module, based on your user permissions. Returns a list of problems if |
| 169 |
there are any, 0 otherwise. |
| 170 |
<P></P></DL> |
| 171 |
<P> |
| 172 |
<HR> |
| 173 |
<H1><A NAME="notes">NOTES</A></H1> |
| 174 |
<P>~/.mtxrc is automatically loaded when this module is used, if it exists, |
| 175 |
using do(). This could cause security problems if you're trying to use |
| 176 |
this with <CODE>setuid()</CODE> programs - so just don't do that. If you want someone |
| 177 |
to have permission to mess with the tape drive and/or changer, let them |
| 178 |
have that permission directly.</P> |
| 179 |
<P> |
| 180 |
<HR> |
| 181 |
<H1><A NAME="requirements">REQUIREMENTS</A></H1> |
| 182 |
<P>Perl 5.6.0 or better, an installed 'mtx' binary, and a tape changer and |
| 183 |
reader connected to the system.</P> |
| 184 |
<P> |
| 185 |
<HR> |
| 186 |
<H1><A NAME="todo">TODO</A></H1> |
| 187 |
<P>Support for Input/Export slots is not included, though it may be later. |
| 188 |
Possibly works for multiple drives per changer, but I haven't tested it, |
| 189 |
so I probably missed something. 'load previous' doesn't actually work, |
| 190 |
because mtx doesn't support it (though the help says it does).</P> |
| 191 |
<P> |
| 192 |
<HR> |
| 193 |
<H1><A NAME="see also">SEE ALSO</A></H1> |
| 194 |
<P><STRONG>mtx</STRONG>, <STRONG>mt</STRONG>, <STRONG>tapechanger</STRONG>. Inspired by <STRONG>stc-changer</STRONG>, which comes |
| 195 |
with the AMANDA tape backup package (http://www.amanda.org), and MTX, |
| 196 |
available at <A HREF="http://mtx.sourceforge.net.">http://mtx.sourceforge.net.</A></P> |
| 197 |
<P> |
| 198 |
<HR> |
| 199 |
<H1><A NAME="author">AUTHOR</A></H1> |
| 200 |
<P>Tim Skirvin <<A HREF="mailto:[email protected]">[email protected]</A>></P> |
| 201 |
<P> |
| 202 |
<HR> |
| 203 |
<H1><A NAME="copyright">COPYRIGHT</A></H1> |
| 204 |
<P>Copyright 2001-2002 by the University of Illinois Board of Trustees and |
| 205 |
Tim Skirvin <<A HREF="mailto:[email protected]">[email protected]</A>>.</P> |
| 206 |
|
| 207 |
</BODY> |
| 208 |
|
| 209 |
</HTML> |