External Target Stage - Command execution error

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
chowdary_kish
Premium Member
Premium Member
Posts: 9
Joined: Tue May 25, 2010 10:27 am

External Target Stage - Command execution error

Post by chowdary_kish »

Hello DS Gurus

My requirement is to create a file with Current Time stamp in the file name and populate same Timestamp in the Header record of the File
ex: File_20111028_142030.txt

header record - HHHHH 20111028142030

-----------

here i'm trying to use DSJobStartTimestamp macro
in External Target Stage im using the following unix command

cat >#path#/bio_`echo #DSJobStartDate# | sed -e 's/-//g'`_`echo #DSJobStartTime# | sed -e 's/://g'`.txt

and I'm getting the following fatal

External_Target_22: Error occurred during initializeFromArgs(). [api/operator.C:672]
External_Target_22: Invalid destination program name specified: Invalid hostname: cat >/dv/resrc_disk1/DS_FDP/target/bio_`echo 2011-10-28 | sed -e 's/-//g'`_`echo 14. [new-impexp/file_export.C:2214]

This is working fine If I'm using only Date part...Time part is not working :(

I need your inputs here solving this error

Note: I want to do this without creating a sequence job - This is in req
Good judgment comes from experience, and experience comes from bad judgment.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Perhaps you need to escape the intermediate underscore?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chowdary_kish
Premium Member
Premium Member
Posts: 9
Joined: Tue May 25, 2010 10:27 am

Post by chowdary_kish »

Im getting same error even without Under score
External_Target_22: Invalid destination program name specified: Invalid hostname: cat >/dv/resrc_disk1/DS_FDP/target/bio_`echo 2011-10-28 | sed -e 's/-//g'``echo 17. [new-impexp/file_export.C:2214]
Good judgment comes from experience, and experience comes from bad judgment.
chowdary_kish
Premium Member
Premium Member
Posts: 9
Joined: Tue May 25, 2010 10:27 am

Post by chowdary_kish »

is there a way I can use the Output of Before Job routine - ExecSh
because im getting it right in there

Sample_Timestamp..BeforeJob (ExecSH): Executed command: echo 2011-10-28 19:16:24 | sed -e 's/-//g' -e 's/ /_/g' -e 's/://g'
*** Output from command was: ***
20111028_191624

I'm thinking of writing the output into a file and reading it from External Target Stage but that will be last option
Good judgment comes from experience, and experience comes from bad judgment.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Sorry... "use it" how / where / for what exactly?
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

You will need to establish the file name before the job runs. You do not have access to the output of the before-job subroutine in the way you wish. If you write the result to a file then, of course, you could read that in an after-job subroutine to change the name of the actual (generic) file name to which the job writes.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
chowdary_kish
Premium Member
Premium Member
Posts: 9
Joined: Tue May 25, 2010 10:27 am

Post by chowdary_kish »

chulett wrote:Sorry... "use it" how / where / for what exactly?
Use the output of the Before Subroutine - ExecSh in the job to pass it as filename
ray.wurlod wrote:You will need to establish the file name before the job runs. You do not have access to the output of the before-job subroutine in the way you wish. If you write the result to a file then, of course ...
I dont have the access to Premium content... :?
I did it by writing the file name into a temp file using Before Job soubRoutine
Then passed the file name in external target stage by reading the temp file..
this may benefit others
Before JobRoutine : echo #DSJobStartTimestamp# | sed -e 's/-//g' -e 's/ /_/g' -e 's/://g' | cat > #DIR#/temp.txt
External Target: cat >#path#/file_`tail -1 temp.txt`.txt
After JobRoutine : rm -f #DIR#/temp.txt

then in after Sub routine I'm deleting the temp file..
I'm marking this post as a work around
and can someone please let me know what is this error about
External_Target_22: Invalid destination program name specified: Invalid hostname: cat >/dv/resrc_disk1/DS_FDP/target/bio_`echo 2011-10-28 | sed -e 's/-//g'``echo 17. [new-impexp/file_export.C:2214]
my guess is that since time has colon (:) in it, Ext tgt stage considering that as some Server name and port number
Good judgment comes from experience, and experience comes from bad judgment.
fmou
Participant
Posts: 124
Joined: Sat May 28, 2011 9:48 pm

Re: External Target Stage - Command execution error

Post by fmou »

chowdary_kish wrote:This is working fine If I'm using only Date part...Time part is not working :(
In this case, try to remove the Date part, just for the testing, and quote the time. I.e.,

Code: Select all

cat >#path#/bio_"`echo "#DSJobStartTime#" | sed -e 's/://g'`".txt
Give it a try and tell us what you get.

HTH
chowdary_kish
Premium Member
Premium Member
Posts: 9
Joined: Tue May 25, 2010 10:27 am

Re: External Target Stage - Command execution error

Post by chowdary_kish »

fmou wrote:
chowdary_kish wrote:This is working fine If I'm using only Date part...Time part is not working :(
In this case, try to remove the Date part, just for the testing, and quote the time. I.e.,

Code: Select all

cat >#path#/bio_"`echo "#DSJobStartTime#" | sed -e 's/://g'`".txt
Give it a try and tell us what you get.

HTH
getting the same error
External_Target_22: Invalid destination program name specified: Invalid hostname: cat >/path/File_"`echo "10
Good judgment comes from experience, and experience comes from bad judgment.
Post Reply