Video Screencast Help
Give us your opinion and win with Symantec! Please help us by taking this survey to tell us about your experience with Symantec Connect, so that we can continue to grow and improve.  Take the survey.

Script to Eject Medias from Tape Library to Media Slots

Created: 06 Jul 2013 • Updated: 09 Jul 2013 | 1 comment
Karthikeyan Sundaram's picture
0 0 Votes
Login to vote
Below mentioned Script takes the media list "D:\Tape_Mgmt_Script\tmpmedialist.txt" as input file and eject those medias as batches to mail slots.
 
Change the robot number as needed on variable "rbnumber"; This script requires all mail slots of library to be free to continue the ejection.
 
and there are 2 empty lines need to be placed end of the input file "D:\Tape_Mgmt_Script\tmpmedialist.txt" to let script identify the end of file.
 
==========================================
On Error Resume Next
Const ForReading = 1
mydate = date()
mc = 0
rbnumber = 0
 
Dim MediaIDInput
 
Set objSysInfo = CreateObject( "WinNTSystemInfo" )
strComputerName = objSysInfo.ComputerName
 
'*********************************************************************************************************************************
'This script is used to do eject the Full Medias to mail slots
' Author - Karthikeyan Sundaram
' Email - Karthikeyan.annur@gmail.com
'*********************************************************************************************************************************
 
Set objShell = CreateObject("Wscript.Shell")
 
Set objFSO = CreateObject("Scripting.FileSystemObject")
 
TmpMListFile = "D:\Tape_Mgmt_Script\tmpmedialist.txt"
 
WScript.echo "Working on identifying the mail slots status"
 
MailSlotStat = "cmd.exe /c vmchange -res -robot_info -verbose -rn " & rbnumber & " -rt tld -rh " & strComputerName & " | findstr Mailslots"
 
Set objExec_MS = objShell.Exec(MailSlotStat)
 
MSStatus = objExec_MS.StdOut.ReadAll
 
MailCountActual = Mid(MSStatus,24,2)
MailCountFree = Mid(MSStatus,28,2)
 
WScript.echo "Total Mail Slots available in tape library is " & MailCountActual
WScript.echo "Free Mail Slots available in tape library is " & MailCountFree
 
Svalue = StrComp(MailCountActual,MailCountFree)
 
If Svalue = 0 then
WScript.echo "All mail slots are available, Good to continue media ejection"
else
WScript.echo "Not All mail slots are empty, Cleanup them"
intButton = objShell.Popup("Not All mail slots are empty, Cleanup the Mail Slots; Once done, Click on OK to continue Media Ejection",,"Attention Needed",48)
End if
 
strMedLine = ""
 
MailSC = MailCountActual-1
 
intButton0 = objShell.Popup("Verify the Input medias on file " & TmpMListFile & ",then give OK to proceed further",,"Attention Needed",48)
 
Set objtmplistFile = objFSO.OpenTextFile(TmpMListFile, ForReading)
 
Do Until objtmplistFile.AtEndOfStream
strMedLine = objtmplistFile.ReadLine
Svalue1 = StrComp(strMedLine,"")
if Svalue1 = 1 then
if mc < MailSC then
If mc = 0 then
bacthtoeject = strMedLine
mc = mc + 1
else
bacthtoeject = bacthtoeject & ":" & strMedLine
mc = mc + 1
 
end if
else
bacthtoeject = bacthtoeject & ":" & strMedLine
WScript.echo "Ejecting medias -" & bacthtoeject
   EjectCommand = "vmchange -res -multi_eject -sec 1 -single_cycle -w -verbose -rn " & rbnumber & " -rt TLD -rh " & strComputerName & " -ml " & bacthtoeject
'objShell.Run("%comspec% /c title Ejecting the tapes |" & EjectCommand), 1, TRUE
intButton3 = objShell.Popup(mc & " Medias has been ejected to Mail slots, Please move them and click one OK",,"Attention Needed",48)
WScript.sleep 6000
mc = 0
bacthtoeject = ""
End if
else
 
WScript.echo "Ejecting medias -" & bacthtoeject
EjectCommand = "vmchange -res -multi_eject -sec 1 -single_cycle -w -verbose -rn " & rbnumber & " -rt TLD -rh " & strComputerName& " -ml " & bacthtoeject
'objShell.Run("%comspec% /c title Ejecting the tapes |" & EjectCommand), 1, TRUE
intButton4 = objShell.Popup(mc & " Medias has been ejected to Mail slots, Please move them and click one OK",,"Attention Needed",48)
WScript.sleep 60000
mc = 0
bacthtoeject = ""
End if
Loop
 

Comments 1 CommentJump to latest comment

Rami Nasser's picture

Thanks for your effort on this script.Could you provide steps how to use it

Regards

0
Login to vote