Modify dsm.opt

TaSMania

ADSM.ORG Member
Joined
Nov 17, 2015
Messages
126
Reaction score
1
Points
0
PREDATAR Control23

Need help automizing dsm.opt. What is a good application to use to execute such a task, batch, vba, perl or others?
1. query for which SP server Node resides on
2. connect to client server and upate dsm.opt:
NODENAME %COMPUTERNAME%
TCPSERVERADDRESS <output from step1>
 
PREDATAR Control23

I am a UNIX/Linux man and I use KSH scripts for most of my TSM automation. However, you will need a "universal" takeoff platform that can update nodes whether these are Windows or UNIX/Linux.

If you are only on just a pure Windows environment, then Batch or Powershell scripts can easily accomplish what you want.
 
PREDATAR Control23

I work with batch and shell, but I can't seem to find the command/code to just open a file and edit then save without changing to different name.
I guess I can script shell to run a second bat file to rename it back.
I guess I need help with:
Search word<node name> in file <dsm.opt> replace following word <node name> with <new node name>
 
PREDATAR Control23

Here is an example of how to replace a TSM server name with a new one and/or replace the TCPPort.

There are 2 DOS batch scripts: The main, called OPT_BAClient.cmd calls a secondary script called dsm_opt.cmd.

(Explanations are in ( ) when called for on the script lines)

OPT_BAClient.cmd:

@echo off

c:
cd "Program Files\Tivoli\TSM\baclient"

REM ****************************************
REM sets the correct TSM Servername and Port
REM ****************************************

call dsm_opt.cmd <old_TSM_ServerName> <new_TSM_ServerName> (use server name that is DNS defined)
call dsm_opt.cmd <old_TCPPort> <new_TCPPort> (use TCPPort number, i.e., 1500)

REM *****************************************************
REM Updates the TSM userid and password on current server
REM *****************************************************

dsmcutil updatepw /node:%COMPUTERNAME% /password:%COMPUTERNAME%

dsm_opt.cmd:

@echo off &setlocal
set "search=%1"
set "replace=%2"
set "textfile=dsm.opt" (This sets the files to be searched and lines to be replaced)
set "newfile=dsm1.opt"
(for /f "delims=" %%i in (%textfile%) do (
set "line=%%i"
setlocal enabledelayedexpansion
set "line=!line:%search%=%replace%!"
echo(!line!
endlocal
))>"%newfile%"
del %textfile%
rename %newfile% %textfile%

Notes:

1. You can add as many lines on the DSM.OPT for to be reaplaced
2. If you need to replace the nodename or COMPUTERNAME, add some substitution commands within OPT_BAClient.cmd
 
PREDATAR Control23

I'm a bit confused. What you offered, I saw already. it's a little much than I need or to follow.

Which step is the one to search word "NODENAME" ?
I do not want to replace NODENAME but anything(unknown) after NODENAME, which would be the server name with %COMPUTERNAME%
 
PREDATAR Control23

I'm a bit confused. What you offered, I saw already. it's a little much than I need or to follow.

Which step is the one to search word "NODENAME" ?
I do not want to replace NODENAME but anything(unknown) after NODENAME, which would be the server name with %COMPUTERNAME%

Then, this will not work for you.

I will see if there is any other way
 
PREDATAR Control23

Thanks for helping. I think scripted something similar awhile back using SHELL get content but can't find it. I'm still googleing and youtubing also :)
 
PREDATAR Control23

I think I'm close to what I'm after but need or missing something here.
I'm using Powershell:
Code:
Get-Content "C:\Program Files\Tivoli\TSM\baclient\dsm.opt" -replace "NODENAME*","NODENAME     %COMPUTERNAME%"  | Set-Content "C:\Program Files\Tivoli\TSM\baclient\dsm2.opt"
 
PREDATAR Control23

Ok I got it!
Code:
$path = "C:\Program Files\Tivoli\TSM\baclient\dsm.opt" 
(Get-Content $path) -replace "nodename(.*)","NODENAME                $env:computername" | out-file $path
 
Top