#!/bin/sh
#!/usr/bin/expect -f

if [ $# -lt 2 ]
then
    echo "Usage : `basename $0` [KIND][FILE]"
    exit
fi

KIND=$1
S_FILE=$2
CON8=_8
S_FILE8=$S_FILE$CON8
export WORK_DATE=`date +"%Y%m%d"`
#export WORK_DATE=20180101
echo $WORK_DATE
SRC_PATH=/app_data/tcs/FILE/SEND
JOB_PATH=/app_data/tcs/FILE/SEND
DESC_PATH=/files/app_data/tcs/FILE/SEND/WORK
# 남산1호터널(구) ID/PASSWD
NSIP=192.168.201.120
NSUSER=tcs
NSPASS=tcs
NSPORT=22

SEND_F=$S_FILE.CSV

#RFID_CARS_INFO 정보를 CSV로 생성
cd $JOB_PATH
iconv -f EUC-KR -t UTF-8 $JOB_PATH/$S_FILE.CSV -o $JOB_PATH/$S_FILE8.CSV
cp $JOB_PATH/$S_FILE8.CSV $SRC_PATH/$SEND_F

#생성된 CSV 파일을 수집서버로 송신
/app/tcs/GREEN_LANE/bin/mput.sh $NSIP $NSUSER $NSPASS $DESC_PATH $SRC_PATH $SEND_F $NSPORT

#수집서버로 ssh접속하여 shell 실행
#KIND: RFID ISS
sshpass ssh -o StrictHostKeyChecking=no $NSUSER@$NSIP /home/tcs/GREEN_LANE/bin/putSever.sh $KIND $SEND_F
