RES: Copy (or transfer) of files between machines
Posted: Mon Jan 12, 2004 12:31 pm
Guillermo writes:
>
Hi Guillermo,
If all three servers (including the DataStage server) are Windows based, such as NT or Windows2000, then you can move or copy files using the DSExecute command and by specifying the UNC path (i.e. \\Path) or with a DataStage job (if you want to read and write the files). But you will need to do a few things with Permissions:
1. In the DataStage Manager, on the Schedule Tab for your project, add a userid (let's say domain\DatastageUID).
2. Grant the DataStageUID and your userid (or group that you are in) permissions to the folder on the two servers you are moving from and to.
Explanation: When you schedule a job, DataStage will use the permissions of the userid specified on the permissions tab (i.e DataStageUID). When you run a job without the scheduler, then permissions from your userid will be used.
Below is some batch code that may be of help to you.
Scott
+++
* Make a double quote version of the parameter file path\Names so that these
* double quoted variables can be used in later commands, so that these
* commands will not fail if there are spaces in the path or name.
DQInputFile = DQuote("\\SomePath\SomeFileIn.txt")
DQOutputFile = DQuote("\\SomePath\SomeFileOut.txt")
* Move the file. Do this by doing the following with each file:
* 1. Use the Move command to move the file.
* 2. Verify the original file name is gone.
* 3. Verify the new file name exists in the move to directory.
* Do the move to the new directory and name
DSECommand = "Move " : DQInputFile : " " : DQOutputFile
Call DSExecute("NT",DSECommand,DSEOutput,DSERC)
If DisplayExtra = "YES" Then
OutMessage = 'DisplayExtra ==> DSEOutput from Move command = ' : DSEOutput
Call DSTransformError(OutMessage, "MoveFile")
End
* Verify the old name is gone
DSECommand = "DIR " : DQInputFile : " /B"
Call DSExecute("NT",DSECommand,DSEOutput,DSERC)
If DSEOutput[1,14] "File Not Found" Then
OutMessage = 'FAILURE to move file ' : DQInputFile
OutMessage = OutMessage : ' to ' : DQOutputFile
OutMessage = OutMessage : ' because the original name still exists after the move.'
Call DSTransformError(OutMessage, "MoveFile")
Return(Ans)
End
* Verify the new name now exists.
DSECommand = "DIR " : DQOutputFile : " /B"
Call DSExecute("NT",DSECommand,DSEOutput,DSERC)
If DSEOutput[1,14] = "File Not Found" Then
OutMessage = 'FAILURE to move file ' : DQInputFile
OutMessage = OutMessage : ' to ' : DQOutputFile
OutMessage = OutMessage : ' because the new name does not exist after the move.'
Call DSTransformError(OutMessage, "MoveFile")
Return(Ans)
End
>
Hi Guillermo,
If all three servers (including the DataStage server) are Windows based, such as NT or Windows2000, then you can move or copy files using the DSExecute command and by specifying the UNC path (i.e. \\Path) or with a DataStage job (if you want to read and write the files). But you will need to do a few things with Permissions:
1. In the DataStage Manager, on the Schedule Tab for your project, add a userid (let's say domain\DatastageUID).
2. Grant the DataStageUID and your userid (or group that you are in) permissions to the folder on the two servers you are moving from and to.
Explanation: When you schedule a job, DataStage will use the permissions of the userid specified on the permissions tab (i.e DataStageUID). When you run a job without the scheduler, then permissions from your userid will be used.
Below is some batch code that may be of help to you.
Scott
+++
* Make a double quote version of the parameter file path\Names so that these
* double quoted variables can be used in later commands, so that these
* commands will not fail if there are spaces in the path or name.
DQInputFile = DQuote("\\SomePath\SomeFileIn.txt")
DQOutputFile = DQuote("\\SomePath\SomeFileOut.txt")
* Move the file. Do this by doing the following with each file:
* 1. Use the Move command to move the file.
* 2. Verify the original file name is gone.
* 3. Verify the new file name exists in the move to directory.
* Do the move to the new directory and name
DSECommand = "Move " : DQInputFile : " " : DQOutputFile
Call DSExecute("NT",DSECommand,DSEOutput,DSERC)
If DisplayExtra = "YES" Then
OutMessage = 'DisplayExtra ==> DSEOutput from Move command = ' : DSEOutput
Call DSTransformError(OutMessage, "MoveFile")
End
* Verify the old name is gone
DSECommand = "DIR " : DQInputFile : " /B"
Call DSExecute("NT",DSECommand,DSEOutput,DSERC)
If DSEOutput[1,14] "File Not Found" Then
OutMessage = 'FAILURE to move file ' : DQInputFile
OutMessage = OutMessage : ' to ' : DQOutputFile
OutMessage = OutMessage : ' because the original name still exists after the move.'
Call DSTransformError(OutMessage, "MoveFile")
Return(Ans)
End
* Verify the new name now exists.
DSECommand = "DIR " : DQOutputFile : " /B"
Call DSExecute("NT",DSECommand,DSEOutput,DSERC)
If DSEOutput[1,14] = "File Not Found" Then
OutMessage = 'FAILURE to move file ' : DQInputFile
OutMessage = OutMessage : ' to ' : DQOutputFile
OutMessage = OutMessage : ' because the new name does not exist after the move.'
Call DSTransformError(OutMessage, "MoveFile")
Return(Ans)
End