There would need to be a Data Protector variable to identify the tape, and no such variable exists. All that is available is:
DATALIST
The name of a backup specification.
MODE
Backup operation type, such as full, incremental, incremental1, incremental2.
OWNER
Owner of the session,
The contents of this variable are in the same format as in the database (case-sensitive):
<user>.<group>@<hostname>
for UNIX
<DOMAIN>\<user>@<hostname>
for Windows
PREVIEW
The value is 1 if a preview is running and 0 if a backup is running. Use this variable to modify your commands
so that they are executed only during a backup and not during a preview. By default, the
pre- or post-exec commands are not executed for preview. You can enable
them by setting the global option ExecScriptOnPreview.
RESTARTED
Set to 1 if this is a restarted backup session, otherwise set to 0. The
post-exec can use this variable to prevent an additional restart in the case that
SMEXIT equals 0.
SESSIONID
Is used to identify a finished session and is recorded in
the database. You cannot use this to preview a session
(use SESSIONKEY).
SESSIONKEY
Is used to identify a running session. You may, for
example, abort a backup session before it is started if
something is wrong.
SMEXIT
The exit code of the Session Manager is the same as the
exit code of the
omnib command. You can only use this
variable with the
post-exec command. Agents can
refer to Disk Agents, Media Agents, Application
Agents, Symmetrix Agents, and so on.
In your script, you could do scan of the tape, for example
omnimm -respository_update "DeviceName" -slot %1
where %1 is a slot number, but, to my knowledge, there is no way to extract the tape information from this. Maybe if someone is really sharp as scripting (which I am not) could figure out a way to do this
I guess you'll have to recycle the tape the old-fashioned way