How to append two text files

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
Seyed
Participant
Posts: 74
Joined: Wed Apr 14, 2010 7:25 am
Location: Oklahoma City

How to append two text files

Post 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
asorrell
Posts: 1707
Joined: Fri Apr 04, 2003 2:00 pm
Location: Colleyville, Texas

Post by asorrell »

Post Job Exec is best way. Since you are on Windows I think the syntax is

copy /b file1+file2 destfile
Last edited by asorrell on Wed Oct 23, 2013 3:10 pm, edited 1 time in total.
Andy Sorrell
Certified DataStage Consultant
IBM Analytics Champion 2009 - 2020
Seyed
Participant
Posts: 74
Joined: Wed Apr 14, 2010 7:25 am
Location: Oklahoma City

Post 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
Seyed
Participant
Posts: 74
Joined: Wed Apr 14, 2010 7:25 am
Location: Oklahoma City

Post 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
asorrell
Posts: 1707
Joined: Fri Apr 04, 2003 2:00 pm
Location: Colleyville, Texas

Post 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!
Andy Sorrell
Certified DataStage Consultant
IBM Analytics Champion 2009 - 2020
Seyed
Participant
Posts: 74
Joined: Wed Apr 14, 2010 7:25 am
Location: Oklahoma City

Post 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
Post Reply