cancel
Showing results for 
Search instead for 
Did you mean: 

script to check the media availability

Gopinathsethu
Level 4

Hi Dudes,

 

I have made a script to chk the media availability

 

 

#!/bin/ksh
 
echo "Dude enter the media id's to check"
 
while read a
 
do
 
echo "\n"
 
nbemmcmd -listmedia -mediaid $a | egrep 'Last Write Host|Robot Number|Date Vaulted'
 
done
 
###############################################################################################################
 
The o/p of above script is the below.
 
Dude enter the media id's to check
L18139
L19979
L20000
 
Last Write Host:                reuxeuus653
Robot Number:                   -
Date Vaulted:                   05/21/2012 10:50
L19979
 
 
Last Write Host:                reuxeuus653
Robot Number:                   8
Date Vaulted:                   -
L20000
 
 
Last Write Host:                reuxeuus653
Robot Number:                   -
Date Vaulted:                   05/21/2012 10:50
 
 
 
The value for this option was missing:
mediaid
Usage:
nbemmcmd -listmedia  [-allrecords] [-brief] [-conflicts] [-emmname <string>]
[-emmport <unsigned integer>] [-mediaid <string>] [-mediatype <unsigned integer>]
[-mergetable] [-poolname <string>] [-robotnumber <unsigned integer>]
[-vaultcontainer <string>]
^C
 
$$$########################################################################
 
 I want to stop  chking mediaids if there is no media id . and if possible please trim the script better ways
 
Thanks & Regards
 
Gopinath S

 

35 REPLIES 35

Andy_Welburn
Level 6

whether it's temporary or not then it'll take just as long!

How are you determining which media that you want to check?

Gopinathsethu
Level 4

If no quoutes "Dude enter list of media id's to check" also no issue:) . But i dont want to go with editing of some file which is located in some other place and calling the file in script.

I know i am bothering you Gys. But really i need  all your helps!!

Thanks & Regards,

Gopinath S

 

Gopinathsethu
Level 4

Actually some Customers will ask for restore

and we will get the media ids in the restore window. then by using vmquery or nbemmcmd will chk whether the tape is avilable in on site or not with the robo number. And valt date is needed when is the tape has vaulted. the last written host is importand to recall the media for the correct lib.

 

Andy_Welburn
Level 6

some other place and calling the file in script."

Put it in the same place as where you run the script from then you don't have to go to two different places!

It *really* isn't too much work, honestly.

 

Again, can I ask where you are getting your list of media that you're then wanting to copy and paste?

***EDIT***

Scrub that last - just seen your most recent post.

Gopinathsethu
Level 4

Hi Andy,

I think i Just realised you 

Could you please give me the final structure of the script.

Thanks & Regards,

Gopinath S

Gopinathsethu
Level 4

Hi Andy 

I have tried my self with u stated above

 

#!/bin/ksh
 
cat tapes.lst|
 
while read a
 
do
 
echo "\n$a"
 
nbemmcmd -listmedia -mediaid $b | egrep 'Last Write Host|Robot Number|Date Vaulted'
 
done
 
root:reuxeuus474# ./mediacheck.sh
cat: cannot open tapes.lst
root:reuxeuus474#
 

 

Gopinathsethu
Level 4

and sorry 

it is 

nbemmcmd -listmedia -mediaid $a | egrep 'Last Write Host|Robot Number|Date Vaulted'

not the below typo error

nbemmcmd -listmedia -mediaid $b | egrep 'Last Write Host|Robot Number|Date Vaulted'

Andy_Welburn
Level 6

https://www-secure.symantec.com/connect/forums/script-check-media-availability#comment-7193571

Altho' you *may* want to make the following amendment(s) (not totally necessary, but ...)

 

Say your script is media_availability.sh & is located in /somedirectorypath/myscripts

- your list of media (which you'd edit each time) would be /somedirectorypath/myscripts/tape.lst

- to be safe you *may* want to change one line in media_availability.sh slightly to cater for this i.e.:

cat /somedirectorypath/myscripts/tape.lst|

Andy_Welburn
Level 6

i.e. mediacheck.sh when run will look in the directory it is being run from to try & find tapes.lst, hence my post (that I wrote as you were testing!) to put in the absolute path to the location of the list of media.

As an aside, the only reason I wasn't happy with pasting a list of media into an actively running script, as I think you wanted originally, was because it throws a carriage return at the end of each media_id & I'm afraid that just couldn't handle that with my scripting ability!

Gopinathsethu
Level 4

Hi Andy,

Thanks for your help!!

 

Now got u. I will check the o/p and get back to you.

Thanks & Regards 

Gopinath S

Gopinathsethu
Level 4

Yes Andy you are right 

with pasting a list of media into an actively running script, that is i wanted originally.

But i  thank you for all your effort with my request.

 

Thanks Mate

 

Gopinathsethu
Level 4

Is there any ways to achive our goal using "sed"

Andy_Welburn
Level 6
The sed utility is a stream editor that reads  one  or  more
text  files,  makes editing changes according to a script of
editing commands, and writes the results to standard output.
The  script  is  obtained  from  either  the  script operand
string, or a combination of the option-arguments from the -e
script and -f script_file options.

 

*May* be able to utilise it somewhere, but this is as far as I got with the utility - bookmarking the following & that was about it, never got the time to even start to research it properly!

http://www.grymoire.com/Unix/Sed.html

Gopinathsethu
Level 4

 

Thanks Mate
 
thinking in another way. The script is taking the i/p as a column. So finding some ways to make it as a row instead of column
 
and got one thing is 
 
Internal field separator
 
IFS='|'
 
But dono how to use it.
 
 
 
 
 

Andy_Welburn
Level 6

functionality to this script, but I feel that the amount of work involved just to run "as is" is minimal & acceptable from an administrative point of view.

If someone told me that to get the information that I required involved editting a file by pasting in a bunch of numbers & then running a script then I would say "Fine. No problem". I *still* feel that this method is as 'long-winded' as being told I needed to run the script then at a particular point I would need to paste in my list of numbers in order to get the information.

In all honesty I cannot see the advantage of pursuing any further options to make this a one-button functionality for what you are likely to gain in the long run - but that's just my point of view.

Gopinathsethu
Level 4

i agree with you Andy,

 

Thanks for your help!!. I have implemented wat u have given successfully. I need another script also. 

 

I will post it in a new Title.

:)

Thanks for all the helping hands!!

Thanks & Regards,

Gopinath S