#!/bin/sh
# Get the KIC position
ac="aclient 130.79.129.161 1660"

# 1) Save the list of KIC numbers
echo2 -n "#...Transfer the list of KIC numbers ..."
tabmap -data -ascii KIC q1-class.dat | $ac save > /tmp/sav$$
ffile=`head -1 /tmp/sav$$`; rm -f /tmp/sav$$
echo2 " => $ffile"

# 2) Get the list of KIC numbers
echo2 "#...$ac kic -i -f $ffile -e p"
$ac kic -i -f $ffile -e p | gawk '/^#KIC/{ K=$2; getline; n++; \
  if(substr($0,1,1) == " ") getline;\
  if(substr($0,1,1)!="#") print $0,";",K; else {\
     print "\t\t;",K; print "#***No pos for KIC", K > "/dev/stderr" } next}\
 /^[# ]/{next}'
