Error Running AWK

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
DS_FocusGroup
Premium Member
Premium Member
Posts: 197
Joined: Sun Jul 15, 2007 11:45 pm
Location: Prague

Error Running AWK

Post by DS_FocusGroup »

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
Premium Member
Posts: 5
Joined: Fri Oct 12, 2007 2:18 pm

Re: Error Running AWK

Post by ColinGorman »

Where is the DataStage Server residing? i.e., Unix or Windows.
ColinGorman
Premium Member
Premium Member
Posts: 5
Joined: Fri Oct 12, 2007 2:18 pm

Re: Error Running AWK

Post by ColinGorman »

Where is the DataStage Server residing? i.e., Unix or Windows.
DS_FocusGroup
Premium Member
Premium Member
Posts: 197
Joined: Sun Jul 15, 2007 11:45 pm
Location: Prague

Post by DS_FocusGroup »

on windows.........
MarkB
Premium Member
Premium Member
Posts: 95
Joined: Fri Oct 27, 2006 9:13 am

Post by MarkB »

What is the actual error you are getting? I take it you are running MKS Toolkit on Windows ...
DS_FocusGroup
Premium Member
Premium Member
Posts: 197
Joined: Sun Jul 15, 2007 11:45 pm
Location: Prague

Post by DS_FocusGroup »

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
Premium Member
Posts: 95
Joined: Fri Oct 27, 2006 9:13 am

Post by MarkB »

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 »

Maybe you are covering the whole command string within a double quotes. Try single quotes over field demiliter (or viceversa)
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

What is the error?
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

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
Premium Member
Posts: 5
Joined: Fri Oct 12, 2007 2:18 pm

Re: Error Running AWK

Post by ColinGorman »

Try to use a simple awk command like, to print "Hello World" and check to make sure awk is working.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

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
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

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
Premium Member
Posts: 197
Joined: Sun Jul 15, 2007 11:45 pm
Location: Prague

Post by DS_FocusGroup »

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

Code: Select all

'"{if (NF==3) print $0}"'
.

If i use double quotes it puts extra single quotes around :roll:

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 »

You should try using \ as the escape caharcter before the single quotes and try, something like this

Code: Select all

\'{if (NF==3) print $0}\'
Post Reply