Page 1 of 1

How to append two text files

Posted: Wed Oct 23, 2013 12:24 pm
by Seyed
Hi all,
I have a server job that writes to two text files. I plan to append the second text file to the first. What is the best way to do this? A calling job sequence will be using the appended text file to email to assigned users.

Thanks,


Seyed

Posted: Wed Oct 23, 2013 12:35 pm
by asorrell
Post Job Exec is best way. Since you are on Windows I think the syntax is

copy /b file1+file2 destfile

Posted: Wed Oct 23, 2013 12:45 pm
by Seyed
Hi Andy,
Appreciate your suggestion. I tried the following,

Code: Select all

copy /b #OFP##FILE_NM# + #OFP##FILE_NM2# output
and then got the following error:

Code: Select all

DataStage Job 224 Phantom 5716
Program "DSP.ActiveRun": Line 51, Exception raised in GCI subroutine:
Access violation.
Attempting to Cleanup after ABORT raised in stage SchemaCompIndexes_test..Command_Stage_74
DataStage Phantom Aborting with @ABORT.CODE = 3
Which looks like a permission issue.

Thanks again,


Seyed

Posted: Wed Oct 23, 2013 1:06 pm
by Seyed
Andy,
I just made the following changes,

Command:

Code: Select all

copy /b #OFP##FILE_NM# + #OFP##FILE_NM2# #OFP##FILE_NM3# 
Output to file

Code: Select all

#OFP##FILE_NM#
I confirmed that the first files were appended and placed into the 3rd file. Next, I would have to do something like

Code: Select all

move /Y #OFP##FILE_NM3# #OFP##FILE_NM# 
However, the job still fails with the same error as before

Code: Select all

DataStage Job 224 Phantom 5664
Program "DSP.ActiveRun": Line 51, Exception raised in GCI subroutine:
Access violation.
Attempting to Cleanup after ABORT raised in stage SchemaCompIndexes_test..Command_Stage_74
DataStage Phantom Aborting with @ABORT.CODE = 3
Thanks again,

Seyed

Posted: Wed Oct 23, 2013 1:52 pm
by asorrell
Seyed,

I don't have access to a Windows install right now to try the command. What I'd suggest is actually putting the command in manually (no parameters) and see if it will actually execute the copy command when it is hardcoded. If that works, then start replacing parameters one at a time to see what causes it to fail.

Also - please note that you might have to add path names to the command to get it to work!

Posted: Wed Oct 23, 2013 2:42 pm
by Seyed
Hi Andy,
Thank you for your help. The problem with errors that I was getting has been resolved. The reason for this error was that I was assigning the 'Output to file' to the same file name as the first input file (#OFP##FILE_NM#). We changed the name to something like (#OFP#FILE_NM#.txt) and that resolved this error. I didn't know that the purpose of the 'Output to file' column was to save the resulting DOS messages.

Continued success,

Seyed