Fetch substring and compare in execute command trigger

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
ureddy
Premium Member
Premium Member
Posts: 36
Joined: Wed May 14, 2008 1:59 pm

Fetch substring and compare in execute command trigger

Post by ureddy »

Hi All,
In execute command im checking the file count using UNIX command wc -l filename.
The output from the command is below
20 filename

Based on the file count i need to run the next jobs(Ex:If file count is 0 then run JOB1 else JOB2.)

I need to fetch only filecount from the above unix command and need to compare filecount>0 or not.
In execute command trigger which logic should i need to provide?

I have tested the below logic in execute command activity trigger but no luck.

Trim(Substrings(Execute_Command_45.$CommandOutput[" ",1,1],1, Len(Execute_Command_45.$CommandOutput))) =0
Either of the jobs(JOB1 or JOB2) are not triggering.

I have created a small server job and hardcoaded a value in transformer stage ("20 filename") and tested the above substring logic and got the output as "20". So its working fine in individual job.
Not sure why its not working at sequence level.

Thanks in advance!

Regards,
Ureddy
Reddy
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Try using an explicit Field() function rather than the delimited substring extraction syntax.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ureddy
Premium Member
Premium Member
Posts: 36
Joined: Wed May 14, 2008 1:59 pm

Post by ureddy »

Hi,

Convert(@FM," ",Execute_Command_45.$CommandOutput) is giving the output as 20 /path/filename
but after applying the Field function its giving ""

Field(Convert(@FM," ",Execute_Command_45.$CommandOutput)," ",1,1)

Any suggestions?

Thanks,
Ureddy
Reddy
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Start simple, what does Field(Execute_Command_45.$CommandOutput," ",1,1) return?
-craig

"You can never have too many knives" -- Logan Nine Fingers
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

If that still doesn't work, probably leading spaces are biting you:

Trim(Field(Execute_Command_45.$CommandOutput," ",1,1))
-craig

"You can never have too many knives" -- Logan Nine Fingers
ureddy
Premium Member
Premium Member
Posts: 36
Joined: Wed May 14, 2008 1:59 pm

Post by ureddy »

Hi Chulett/Ray,

Below function working fine and giving the only record count as output.

Field(Trim(Convert(@FM," ",Execute_Command_45.$CommandOutput))," ",1,1)

Thanks for everything.

Regards,
Ureddy
Reddy
anbu
Premium Member
Premium Member
Posts: 596
Joined: Sat Feb 18, 2006 2:25 am
Location: india

Post by anbu »

This way you can avoid filename in the output of wc command

Code: Select all

wc -l < filename
You are the creator of your destiny - Swami Vivekananda
Post Reply