TSM Script


Script is a good tool for managing TSM, especially for automating tasks. A simple example is to create a schedule to run the script which backs up the TSM database.

In this post, I am going to show you how to create, check and delete a script. Run the following command in TSM console is to check the number of the scratch tapes in the tape library –

select count(*) as scratch_count from libvolumes where status=’Scratch’

As you can imagine it is not convenient to type or copy/paste the command every time you want to run it. Creating a script is the solution to simplify it.

1) Define the script and give it a name ‘q_scratch’

tsm: sandbox>define script q_scratch “select count(*) as scratch_count from libvolumes where status=’Scratch'” line=5 Description=”The scratch tapes numbers”
ANR1454I DEFINE SCRIPT: Command script Q_SCRATCH defined.

2) Run the script

tsm: sandbox>run q_scratch
SCRATCH_COUNT
————–
59
ANR1462I RUN: Command script Q_SCRATCH completed successfully.

3) Check the script in different formats (detail, line, raw and macro). Note different formats will provide you the flexibility when moving the scripts across different TSM servers.

tsm: sandbox>q script q_scratch f=d

Name: Q_SCRATCH
Line Number: Description
Command: The scratch tapes numbers
Last Update by (administrator): ADMIN1
Last Update Date/Time: 02/28/2014 16:47:15

Name: Q_SCRATCH
Line Number: 5
Command: select count(*) as scratch_count from libvolumes where status=’Scratch’
Last Update by (administrator): ADMIN1
Last Update Date/Time: 02/28/2014 16:47:15

tsm: sandbox>q script q_scratch f=l

Name Line Command
Number
———- —— ————————————————————
Q_SCRATCH 5 select count(*) as scratch_count from libvolumes where status=’Scratch’

tsm: sandbox>q script q_scratch f=r
select count(*) as scratch_count from libvolumes where status=’Scratch’

tsm: sandbox>q script q_scratch f=m
DEFINE SCRIPT Q_SCRATCH DESC=”The scratch tapes numbers”
UPDATE SCRIPT Q_SCRATCH “select count(*) as scratch_count from libvolumes where status=’Scratch'”

Image

4) With the above commands, I can export the script in raw format to a file and import it to another TSM server. Or copy/paste the results that is in macro format and run it into another TSM server’s console. A example to export the q_scratch script, and delete it, then create it again from the exported file.

tsm: sandbox>q script q_scratch f=r > c:\q_scratch
Output of command redirected to file ‘C:\Q_SCRATCH’

tsm: sandbox>del script q_scratch

Do you wish to proceed? (Yes (Y)/No (N)) y
ANR1457I DELETE SCRIPT: Command script Q_SCRATCH deleted.

tsm: sandbox>run q_scratch
ANR1455E RUN: Command script Q_SCRATCH does not exist.
ANS8001I Return code 11.

tsm: sandbox>def script q_scratch file=c:\q_scratch
ANR1454I DEFINE SCRIPT: Command script Q_SCRATCH defined.

tsm: sandbox>run q_scratch
SCRATCH_COUNT
————–
59
ANR1462I RUN: Command script Q_SCRATCH completed successfully.

Image

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s