Page 1 of 1

Command Activity

Posted: Sat May 21, 2011 3:43 pm
by prasad v
Hi

I am trying to retrieve data from file using commmand Activity stage in datastage

Actually i have created file with 1 value.
And used cat <filename>
Displayed Output: 1 and showing extraline(Eg: 1
)

I tried checking with Len(that commandactivity_output). It is giving 2.

How can we extract only the value 1 using Command Activity stage as i am passing this value to parameter.

And This file is being created in Command Activity stage later this stage.

Thanks
Prasad

Posted: Sat May 21, 2011 4:53 pm
by ray.wurlod
Extract the first element from the field-mark-delimited string returned via the Execute Command activity's output activity variable.

Use Field() function or dynamic array notation (ExecCmd.Output$<1>).

Posted: Sun May 22, 2011 12:07 am
by prasad v
Thanks Ray.

There is no delimiter in the file. so what can be used in Field() function. length of this value will vary everytime such as 1234 or 1 or 1234565 or 1223333333.

Can you please advise me how to write the Field() function in this situation.

Thanks
Prasad

Posted: Sun May 22, 2011 6:09 am
by chulett
He already stated the returned value was "field mark delimited". A Field Mark is one of the many System Variables you should be familiar with.

Posted: Mon May 23, 2011 12:15 pm
by arunkumarmm
Its @FM

Posted: Tue May 24, 2011 6:01 am
by prasad v
Thanks to All.

I have done this using the below code in command activity stage in sequence.

Code: Select all

value=$(cat FileName);printf "$value"