Page 1 of 1

External Target Stage - Command execution error

Posted: Fri Oct 28, 2011 12:45 pm
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

Posted: Fri Oct 28, 2011 3:26 pm
by ray.wurlod
Perhaps you need to escape the intermediate underscore?

Posted: Fri Oct 28, 2011 3:41 pm
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]

Posted: Fri Oct 28, 2011 5:21 pm
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

Posted: Fri Oct 28, 2011 6:08 pm
by chulett
Sorry... "use it" how / where / for what exactly?

Posted: Sat Oct 29, 2011 5:29 am
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.

Posted: Sat Oct 29, 2011 1:42 pm
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

Re: External Target Stage - Command execution error

Posted: Sun Oct 30, 2011 8:22 am
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

Re: External Target Stage - Command execution error

Posted: Mon Oct 31, 2011 8:37 am
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