HP UX and AIX compatibility issue

Hi All,
The below code works perfectly on AIX machine but doesnt give the desired o/p on HP UX.
Can someone please generalise the code so that it becomes platform independent.


awk 'NR == FNR {
  /^[ \t]*\47name/ && c++      # get the field number
  if (/^[ \t]*\47size/) {
    split($0, t, ":")          
    gsub(/[ \t\47,]/, x, t[2]) # strip punctuation
    fmt[c] = t[2]              # get the size 
    }
  next                         # run the above actions                                     
  }                            # + only for the first input file
{ 
  for (i=1; i<=NF; i++)        # output the strings in the correct format
    printf "%" (length($i) > fmt ? "." : "-" ) fmt "s", $i           
  print x
  }' config.txt temp.txt

I should imagine a look at config.txt and temp.txt would raise your chances of getting a sensible reply considerably. Not to mention a glimps of the output on both platforms??

In the mean time have you tried using nawk?

The input temp.txt

1       12      123     1234    1
A       AB      ABC     ABDC    e

config.txt

{
                        'name'  :       'Field1',
                        'type'  :       'input',
                        'spos'  :       1,
                        'size'  :       2,
                },
                {
                        'name'  :       'Field2',
                        'type'  :       'input',
                        'spos'  :       3,
                        'size'  :       2,
                },
                {
                        'name'  :       'Field3',
                        'type'  :       'input',
                        'spos'  :       5,
                        'size'  :       8,
                },
                {
                        'name'  :       'Field4',
                        'type'  :       'input',
                        'spos'  :       13,
                        'size'  :       11,
                },
                {
                        'name'  :       'Field5',
                        'type'  :       'input',
                        'spos'  :       24,
                        'size'  :       11,
                },


OUTPUT in HP-AX is as follows 
1 12123     12341
A ABABC     ABDCe

Expected is 
1 12123     1234       1
A ABABC     ABDC       e

the output comes as expected in AIX. and nawk isnt recognised in HP unix