Tech Support > Operating Systems > MS-DOS > Piping the contents of one file to another
Piping the contents of one file to another
Posted by bladeraptor on January 3rd, 2007


Hi

Following on from Foxdrive's great help yesterday in showing me how to
extract some text from a file - I have discovered that I need to import
that information into another batch file

I have scoured the boards and can't find a way of taking the
information extracted from the one text file and piping it into another
file

So I have exported the relevant lines from the output of dumpcfg.exe to
text files (with the drive number as the text file name) and now need
to move that hex value from those text files to the batch file that
creates the cluster resource

Ideally I need the value to get piped so I can use it as the variable -
i.e - Have the batch appended with the piped variable as the last line
and I can then call it as a set variable - so would need to call the
last line, i.e

call:var

cluster.exe /CLUSTER:RMSEISCSIDR1 group "NS_EXCH_PS1" /offline
cluster.exe /CLUSTER:RMSEISCSIDR1 resource "NS_EXCH_PS1 Data" /CREATE
/GROUP:"NS_EXCH_PS1" /TYPE:"Physical Disk"
cluster.exe /CLUSTER:RMSEISCSIDR1 resource "NS_EXCH_PS1 Data" /priv
signature=0x%bob%
cluster.exe /CLUSTER:RMSEISCSIDR1 resource "NS_EXCH_PS1 Data" /online
cluster.exe /CLUSTER:RMSEISCSIDR1 resource "NS_EXCH_PS1 Logs" /CREATE
/GROUP:"NS_EXCH_PS1" /TYPE:"Physical Disk"
cluster.exe /CLUSTER:RMSEISCSIDR1 resource "NS_EXCH_PS1 Logs" /priv
signature=0x%bob%
cluster.exe /CLUSTER:RMSEISCSIDR1 resource "NS_EXCH_PS1 Logs" /online
cluster.exe /CLUSTER:RMSEISCSIDR1 resource "NS_EXCH_PS1 SA"
/adddependency:"NS_EXCH_PS1 Data"
cluster.exe /CLUSTER:RMSEISCSIDR1 resource "NS_EXCH_PS1 SA"
/adddependency:"NS_EXCH_PS1 Logs"

:var
set bob=0xEE06E1AF <- this is the disk signature piped from the other
text file

Do you know how this would could be done - many thanks

Alex Tanner

Posted by foxidrive on January 3rd, 2007


On 3 Jan 2007 08:06:46 -0800, "bladeraptor" <bladeraptor@hotmail.com>
wrote:

Can you call a batch file (using the sample) with the data as it is parsed?

@echo off
setlocal
for /f "tokens=1,2 delims=:" %%a in (
'type "dumpcfg.file"'
) do call :next "%%a" %%b
GOTO:EOF
:next
if "%~1"=="Disk Number" set num=%2&goto :EOF
if "%~1"=="Signature" call cluster.cmd %num% %2
(set num=)



And in cluster.cmd this will have the disk items in the replaceable
parameters:

@echo off
echo %1 %2



If you give some specifics of how the original data is being used in the
batch file it would help to see how it all hangs together.



Posted by bladeraptor on January 3rd, 2007


Hi Foxdrive

Once again thanks for your help. For the sake of clarity, let me
explain what I am trying to do from the top.

I am testing an internal solution for a Disaster Recovery Solution
using iSCSI. We replicate the iSCSI LUNs to the DR site and present
them to a DR cluster and the bring that cluster online. This solution
is designed to allow you to fail backwards and forwards. The problem
with this is that when the DR side of the relationship is passive the
iSCSI LUNs are not exposed to the host.

When you fail over and need to expose the LUNs - they are seen as brand
new disk resources by Windows and the clusters - so scripting the
creation of a physical disk cluster resource is difficult as a disk
signature is required so cluster.exe knows which disk to use . The
problem is that the disk signature is different everytime the iSCSI
LUNs are exposed to the cluster.

Now dumpcfg.exe can query Windows and discover the disk signature.
However I then need to get the disk signatures discovered by
dumpcfg.exe piped directly into the cluster resource create batch or
piped to a text file and from there get the values into the cluster
resource create batch.

The problem is that I only need the disk signatures for disks 4,5,6
rather than all the disks 0-7 piped to the cluster resource create
batch, which I have copied below. From the example below - you can see
where the variables (i.e. the disk signatures need to appear) to create
the cluster physical disk resources correctly

cluster.exe /CLUSTER:RMSEISCSIPS1 resource "NS_EXCH_PS1 Physical Disk
Data" /CREATE /GROUP:"NS_EXCH_PS1" /TYPE:"Physical Disk"
cluster.exe /CLUSTER:RMSEISCSIPS1 resource "NS_EXCH_PS1 Physical Disk
Data" /priv signature=%variable%
cluster.exe /CLUSTER:RMSEISCSIPS1 resource "NS_EXCH_PS1 Physical Disk
Data" /online
cluster.exe /CLUSTER:RMSEISCSIPS1 resource "NS_EXCH_PS1 Physical Disk
Logs" /CREATE /GROUP:"NS_EXCH_PS1" /TYPE:"Physical Disk"
cluster.exe /CLUSTER:RMSEISCSIPS1 resource "NS_EXCH_PS1 Physical Disk
Logs" /priv signature=0x%variable%
cluster.exe /CLUSTER:RMSEISCSIPS1 resource "NS_EXCH_PS1 Physical Disk
Logs" /online
cluster.exe /CLUSTER:RMSEISCSIPS1 resource "NS_EXCH_PS1 SA"
/adddependency:"NS_EXCH_PS1 Physical Disk Data"
cluster.exe /CLUSTER:RMSEISCSIPS1 resource "NS_EXCH_PS1 SA"
/adddependency:"NS_EXCH_PS1 Physical Disk Logs"

So either way I need to get the variables from the output of
dumpcfg.exe into the cluster resource create batch

Many thanks once again for your help

Kind regards

Alex Tanner

foxidrive wrote:

Posted by bladeraptor on January 3rd, 2007


Hi Foxidrive

Once again your insights have inspired a resolution

If I take your suggestion and tweak the top of the cluster resource
creation batch to include the following

@echo off
echo %1 %2

if "%1"=="0" goto :end
if "%1"=="1" goto :end
if "%1"=="2" goto :end
if "%1"=="3" goto :end
if "%1"=="4" goto :RMSE
if "%1"=="5" goto :EXCH1
if "%1"=="6" goto :EXCH2
if "%1"=="7" goto :end
GOTO:EOF

:RMSE
cluster.exe /CLUSTER:RMSEISCSIPS1 resource "Replication Manager SE
Database Physical Disk " /CREATE /GROUP:"Replication Manager SE
Database " /TYPE:"Physical Disk"
cluster.exe /CLUSTER:RMSEISCSIPS1 resource "Replication Manager SE
Database Physical Disk /priv signature=%2%
cluster.exe /CLUSTER:RMSEISCSIPS1 resource "Replication Manager SE
Database Physical Disk " /online
GOTO:EOF


:EXCH1
cluster.exe /CLUSTER:RMSEISCSIPS1 resource "NS_EXCH_PS1 Physical Disk
Data" /CREATE /GROUP:"NS_EXCH_PS1" /TYPE:"Physical Disk"
cluster.exe /CLUSTER:RMSEISCSIPS1 resource "NS_EXCH_PS1 Physical Disk
Data" /priv signature=%2%
cluster.exe /CLUSTER:RMSEISCSIPS1 resource "NS_EXCH_PS1 Physical Disk
Data" /online
GOTO:EOF

:EXCH2
cluster.exe /CLUSTER:RMSEISCSIPS1 resource "NS_EXCH_PS1 Physical Disk
Logs" /CREATE /GROUP:"NS_EXCH_PS1" /TYPE:"Physical Disk"
cluster.exe /CLUSTER:RMSEISCSIPS1 resource "NS_EXCH_PS1 Physical Disk
Logs" /priv signature=%2%
cluster.exe /CLUSTER:RMSEISCSIPS1 resource "NS_EXCH_PS1 Physical Disk
Logs" /online
GOTO:EOF

:end

I have a resolution that seems to work

Many thanks again for your help and expertise

Regards

Alex Tanner

foxidrive wrote:

Posted by foxidrive on January 4th, 2007


On 3 Jan 2007 14:34:57 -0800, "bladeraptor" <bladeraptor@hotmail.com>
wrote:

An excellent solution. A minor point I notice is that you can filter only
the drive numbers you want and let all the rest fall though to the GOTO
:EOF

@echo off
echo %1 %2

if "%1"=="4" goto :RMSE
if "%1"=="5" goto :EXCH1
if "%1"=="6" goto :EXCH2
GOTO :EOF


Also, the replaceable parameter above should be simply %2
Environment variables are enclosed on both sides by % signs.

I'm pleased to see your solution. Cheers.



Similar Posts