Page 1 of 1

Fetch substring and compare in execute command trigger

Posted: Mon Apr 19, 2010 4:19 am
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

Posted: Mon Apr 19, 2010 4:32 am
by ray.wurlod
Try using an explicit Field() function rather than the delimited substring extraction syntax.

Posted: Mon Apr 19, 2010 5:59 am
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

Posted: Mon Apr 19, 2010 6:01 am
by chulett
Start simple, what does Field(Execute_Command_45.$CommandOutput," ",1,1) return?

Posted: Mon Apr 19, 2010 6:03 am
by chulett
If that still doesn't work, probably leading spaces are biting you:

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

Posted: Mon Apr 19, 2010 6:58 am
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

Posted: Mon Apr 19, 2010 7:51 am
by anbu
This way you can avoid filename in the output of wc command

Code: Select all

wc -l < filename