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
DS_FocusGroup
Premium Member
Posts: 197 Joined: Sun Jul 15, 2007 11:45 pm
Location: Prague
Post
by DS_FocusGroup » Tue Apr 07, 2009 2:01 am
Hi,
I am trying to run an awk command in datastage through command stage. The command run fines if i run it on DOS command prompt but when i run it in DS its giving me an error. Its a pipe delimited file
Code: Select all
awk -F "|" '{if (NF==3) print $0}' source file > output_file
Thanks.
ColinGorman
Premium Member
Posts: 5 Joined: Fri Oct 12, 2007 2:18 pm
Post
by ColinGorman » Tue Apr 07, 2009 4:20 am
Where is the DataStage Server residing? i.e., Unix or Windows.
ColinGorman
Premium Member
Posts: 5 Joined: Fri Oct 12, 2007 2:18 pm
Post
by ColinGorman » Tue Apr 07, 2009 4:22 am
Where is the DataStage Server residing? i.e., Unix or Windows.
MarkB
Premium Member
Posts: 95 Joined: Fri Oct 27, 2006 9:13 am
Post
by MarkB » Tue Apr 07, 2009 5:05 am
What is the actual error you are getting? I take it you are running MKS Toolkit on Windows ...
DS_FocusGroup
Premium Member
Posts: 197 Joined: Sun Jul 15, 2007 11:45 pm
Location: Prague
Post
by DS_FocusGroup » Tue Apr 07, 2009 5:12 am
Command failed to execute - Missing field separator '"{if (NF==3) print $0}"' is not recognized as an internal or external command, operable program or batch file.
Thanks
MarkB
Premium Member
Posts: 95 Joined: Fri Oct 27, 2006 9:13 am
Post
by MarkB » Tue Apr 07, 2009 5:30 am
Check to make sure awk is in a path accessible to DataStage.
Sainath.Srinivasan
Participant
Posts: 3337 Joined: Mon Jan 17, 2005 4:49 am
Location: United Kingdom
Post
by Sainath.Srinivasan » Tue Apr 07, 2009 6:04 am
Maybe you are covering the whole command string within a double quotes. Try single quotes over field demiliter (or viceversa)
DSguru2B
Charter Member
Posts: 6854 Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX
Post
by DSguru2B » Tue Apr 07, 2009 8:15 am
What is the error?
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
chulett
Charter Member
Posts: 43085 Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO
Post
by chulett » Tue Apr 07, 2009 8:19 am
The error:
DS_FocusGroup wrote: Command failed to execute - Missing field separator '"{if (NF==3) print $0}"' is not recognized as an internal or external command, operable program or batch file.
-craig
"You can never have too many knives" -- Logan Nine Fingers
ColinGorman
Premium Member
Posts: 5 Joined: Fri Oct 12, 2007 2:18 pm
Post
by ColinGorman » Tue Apr 07, 2009 9:22 am
Try to use a simple awk command like, to print "Hello World" and check to make sure awk is working.
chulett
Charter Member
Posts: 43085 Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO
Post
by chulett » Tue Apr 07, 2009 9:32 am
A common problem with approaches like this are quotes get stripped and that looks to be what's going on here. Either escape them or put the awk statement in a .bat file and execute the batch file.
-craig
"You can never have too many knives" -- Logan Nine Fingers
DSguru2B
Charter Member
Posts: 6854 Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX
Post
by DSguru2B » Tue Apr 07, 2009 12:11 pm
Did you try splitting the job so that you can invoke the command in the before/after job subroutines?
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
DS_FocusGroup
Premium Member
Posts: 197 Joined: Sun Jul 15, 2007 11:45 pm
Location: Prague
Post
by DS_FocusGroup » Wed Apr 08, 2009 2:31 am
yes the awk is accesible from DS as i am running another awk in some job.
the problem i see is that its putting extra single quotes around the
.
If i use double quotes it puts extra single quotes around
Not sure why ? as i have tried without any quotes but then it comes up with
P.S works fine if run through the batch file......
wahi80
Participant
Posts: 214 Joined: Thu Feb 07, 2008 4:37 pm
Post
by wahi80 » Wed Apr 08, 2009 10:14 am
You should try using \ as the escape caharcter before the single quotes and try, something like this