Page 1 of 1

Getting error in $CommandOutput

Posted: Thu Sep 01, 2011 11:32 am
by moupanja
Hi All,

I'm using execute command stage to read each line of a file at a time. The file looks like~
3,123
4,456
2,677

Now when the sequencer runs for the first time, exec command reads the first line i.e 3,123. The value 3 is then passed to one of the job parameter A and the value 123 is assigned to another job parameter B.
Again for 2nd run it will assign the values from 2nd line in similar manner...and so on .
I'm extracting the first value by
A=Field(Execute_Command_0.$CommandOutput, "," ,1, 1)
B=Field(Execute_Command_0.$CommandOutput, "," ,2, 1)
But its throwing the following error~
Controller problem: Error calling DSSetParam(Account_ID), code=-4
[ParamValue/Limitvalue is not appropriate]

Can anyone help me please?

Posted: Thu Sep 01, 2011 12:46 pm
by chulett
Actually, you should be able to help yourself. Do an exact search of the forums for "ParamValue/Limitvalue is not appropriate" and you'll find this has been discussed many times.

Posted: Thu Sep 01, 2011 5:14 pm
by ray.wurlod
Does your file have an empty last line?

Posted: Thu Sep 01, 2011 9:45 pm
by moupanja
Hi Ray,

The file has no new line at the end.
I've also checked in the forum and it is recommended to use @FM, so I tried with this command~
Field(Execute_Command_0.$CommandOutput,@FM ,2, 1)
but even then I'm getting the same error!
Is it an incorrect command?
Also can you please explain me why do we use @FM?

Posted: Thu Sep 01, 2011 10:14 pm
by ray.wurlod
Line terminators are mapped to @FM. In your case you correctly (originally) specified comma as the delimiter.

The problem is probably with the line terminators in your file. Can you please share how you are implementing "read each line of a file at a time"?

Posted: Fri Sep 02, 2011 7:27 am
by akshu.agni
Use

Ereplace(Execute_Command_0.$CommandOutput,@FM,'' )

Posted: Fri Sep 02, 2011 7:57 am
by ray.wurlod
:?
Why?
The file is being read one line at a time (allegedly).

Posted: Fri Sep 02, 2011 8:54 am
by moupanja
ray.wurlod wrote:Line terminators are mapped to @FM. In your case you correctly (originally) specified comma as the delimiter.

The problem is probably with the line terminators in your file. Can you please share how you are implementing "read each line of a file at a time"?
Hi Ray,

My design is like~

Start Loop-->Exec Command-->MyJob-->End Loop

In the Exec Command stage I'm giving this command to fetch each line at a time:
sed -n '#StartLoop_Activity_3.$Counter#p' <filename>
I have set the counter from 1 to 3 to read the three lines.

Posted: Sat Sep 03, 2011 2:27 am
by ray.wurlod
Try this approach. Read the entire file before the loop. Convert the line terminators into, say, pipe characters and use that to delimit your "list of things" loop. Within the loop use Field() functions to parse the comma-delimited lines.

Code: Select all

ExecuteCommand:  cat #filename# | tr '\n' '|'
StartLoop:  Delimiter = "|"
Parameter derivation 1:  Field(StartLoop.$Counter, ",", 1, 1)
Parameter derivation 2:  Field(StartLoop.$Counter, ",", 2, 1)
It's probably useful also to check that $Counter is not empty - perhaps a NestedCondition activity.

Posted: Mon Sep 05, 2011 12:29 am
by moupanja
Hi Ray,

Thanks a lot for the workaround!
Although my job has finished successfully and generating the desired output but the sequencer is aborting with the same error for the 4th iteration.
Since the output of your Exec command is generating a '|' delimiter at the end of the last record too hence the loop is going for 4 iterations instead of 3.
Its throwing the error only for the 4th iteration~
seq_num_rec_1..JobControl (@StartLoop_Activity_3): Loop through list (4 items): iteration 4
seq_num_rec_1..JobControl (@Job_Activity_5): Controller problem: Error calling DSSetParam(No_of_Rec), code=-4
[ParamValue/Limitvalue is not appropriate]


I tried to write a script to eliminate the last '|' charecter from the output of the command cat #filename# | tr '\n' '|', but even then its giving the same error!
Any suggestions for this problem?

Posted: Mon Sep 05, 2011 1:57 am
by priyadarshikunal
ray.wurlod wrote:It's probably useful also to check that $Counter is not empty - perhaps a NestedCondition activity.
Did you check this?

Posted: Mon Sep 05, 2011 7:45 am
by chulett
Or attempt again to remove the last delimiter. Not sure what you tried, but you should be able to simply substring what you need before it hits the Start Loop. Take everything from 1 through (length-1).