Using echo in AWK

Hello,
I have written the script below to extract specific data from a text file and then use the data extracted as parameters for another shell script call 'loto_tsim'.
Everytime I run my script it complains about the 'echo' line. Am I missing something? I have spent hours and still cannot solve this, can anyone help?

#!/bin/sh

awk 'NR==1 {n = split($3, array, "-");
lotoE="1\n 20\n 0\n 0\n 1\n 1\n 7\n 0\n array[1]\n array[2]\n array[3]\n array[4]\n array[5]\n array[6]\n 1\n 1\n 0\n 0\n 0\n N\n 1\n 100\n"

echo ${lotoE} | $LOTO/bin/loto_tsim > /dev/null 2>&1

}' LottWagers2.txt

----------------------THIS IS THE ERROR------------------------------
Syntax Error The source line is 6.
The error context is
echo >>> ${ <<<
awk: 0602-502 The statement cannot be correctly parsed. The source line is 6.

It's because there is not an echo statement in awk ...

Thanks radoulov. Would you happen to know how I can resolve this?

Yes,
if you try to explain what exactly you are trying to achieve.
Could you post a sample of the LottWagers2.txt file content and an example of the $LOTO/bin/loto_tsim output.

Hello Radoulov,
the subset of the text file content is below. the loto_tsim was written by someone else and works perfectly, allowing the user to enter specific information from and then the simulator does some processing in the background. The problem is that the original script were using static values, but some of the ebrty we need to be generic hence the reason why I am reading some of the values from a defined test file.

-----Format of Content of text file -----
1 1 01-02-25-26-27-28 (99) Both 1
1 1 26-27-28-29-30-31 (31) Both 1
1 1 01-02-27-28-29-30 (99) Both 1
1 1 01-02-03-04-05-06 (99) Both 1

loto_sim (another shell script someone else wrote) is expecting certain values to be entered from teh command line. the values I am supplying are in lotoE. If I was not using awk, I could have echo the values in, but becuse I used awk to read in specific data from a text file, I don't think awk understands 'echo'

If you really need to read only the first line of LottWagers2.txt,
something like this may work:

( read a b c d< LottWagers2.txt
  IFS=-
  printf ' 1\n 20\n 0\n 0\n 1\n 1\n 7\n 0\n'
  printf ' %s\n' $c
  printf ' 1\n 1\n 0\n 0\n 0\n N\n 1\n 100\n' ) | 
  "$LOTO"/bin/loto_tsim > /dev/null 2>&1

Please put code inside

 tags.


 
#!/bin/sh
 
awk 'NR==1 {n = split($3, array, "-");
lotoE="1\n 20\n 0\n 0\n 1\n 1\n 7\n 0\n array[1]\n array[2]\n array[3]\n array[4]\n array[5]\n array[6]\n 1\n 1\n 0\n 0\n 0\n N\n 1\n 100\n"
 
echo ${lotoE} | $LOTO/bin/loto_tsim > /dev/null 2>&1

[/quote]

[indent]
There is no echo statement in awk; use print or printf.

You also cannot use shell variables inside awk. Pass them to awk with the -v option:

awk -v var="$3" 'NR==1 {n = split(var, array, "-") ...'

But, as radoulov pointed out, why use awk?

The problem with this is that I only want to read in the the 01-02-25-26-27-28 and then split teh number in 01 02 25 etc because the tSim only accept one digit at a time

1 1 01-02-25-26-27-28 (99) Both 1

read a b c d < LottWagers2.txt
IFS=-
set -- $c
printf "%s\n" "$@" | "$LOTO"/bin/loto_tsim 

Thank you very much OH GREAT MASTERS. I will try this and see if it work.
Darn I will have to do this in the morning some trigger finger just killed the whole system to I cannot get on.
But thank you guuys very much, hopefully it works in the morning