1. Forum Rules (PLEASE CLICK HERE TO READ BEFORE POSTING) Click the link to access ADSM.ORG Acceptable Use Policy and forum rules which should be observed when using this website. Violators may be banned from this website. This message will disappear after you have made at least 12 posts. Thank you for your cooperation.

Decision scripting in TSM

Discussion in 'Scripting' started by pfsubaru, Jun 14, 2012.

  1. pfsubaru

    pfsubaru New Member

    Joined:
    Jan 24, 2009
    Messages:
    150
    Likes Received:
    0
    Hi All,

    I am looking for some information on decision syntax in TSM scripting. This is what I am planning to do, I want to write a script that can check what day of the week is it and base on the day will excute a certain set of command.

    Anybody can provide some clue?

    Thanks in advance.
     
  2.  
  3. moon-buddy

    moon-buddy Moderator

    Joined:
    Aug 24, 2005
    Messages:
    6,159
    Likes Received:
    276
    Occupation:
    Electronics Engineer, Security Professional
    Location:
    Somewhere in the US
    Windows or Unix?

    Script must be done outside of TSM.
     
  4. pfsubaru

    pfsubaru New Member

    Joined:
    Jan 24, 2009
    Messages:
    150
    Likes Received:
    0
    Windows. Do you think you can provide some example?
     
  5. moon-buddy

    moon-buddy Moderator

    Joined:
    Aug 24, 2005
    Messages:
    6,159
    Likes Received:
    276
    Occupation:
    Electronics Engineer, Security Professional
    Location:
    Somewhere in the US
    @echo off

    set DAY=%DATE:~0,3%
    set COMD=dsmadmc -id=admin -pa=passsword -noc -dataonly=yes


    IF %DAY% equ Mon (
    %COMD% "some TSM command in double quotes"
    )

    IF %DAY% equ Tue (
    %COMD% "some TSM command in double quotes"
    )

    etc...
     
  6. rmazzon

    rmazzon Senior Member

    Joined:
    Dec 6, 2004
    Messages:
    207
    Likes Received:
    17
    Occupation:
    TSM Managed Services Lead
    Location:
    NC
    What follows applies to TSM 5.5.x. I don't know about 6.x. But in 5.5.x you can use a command like
    select dayofweek(current_timestamp) from status
    to return a number from 1 (Sunday) to 7 (Saturday) and build some logic around that.

    So something like what follows will return either an rc_ok if true or rc_notfound if false (example is looking for Sunday)

    select server_name from status where dayofweek(current_timestamp)=1

    And you can expand this into a TSM script along the lines of this

    select server_name from status where dayofweek(current_timestamp)=1
    if(rc_notfound) goto next1
    <insert your commands here>
    goto exit
    next1:
    select server_name from status where dayofweek(current_timestamp)=2
    if(rc_notfound) goto next2
    <insert your commands here>
    goto exit
    next2:
    ..... <etc>
    exit:
    exit
     

Share This Page