我一直在编写一个shell脚本来从数据库中获取一些数据,将其放入csv文件,然后将该csv文件传输到另一个位置。
由于该位置可以是另一台使用scp(安全副本)的服务器。但我收到以下错误:
demo.sh: DEST_PATH: not found
usage: scp [-12346BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file]
[-l limit] [-o ssh_option] [-P port] [-S program]
[[user@]host1:]file1 ... [[user@]host2:]file2
以下是我目前编码的脚本:
#!/usr/bin/bash
#import properties files
. <<propertyfilePath>>.properties
##############################################################
# Initializing Variables
##############################################################
#USER_CMD=`who am i`
#USER=`echo $USER_CMD|tr -s " "| cut -d " " -f1`
#Making the log file in user home directory
LOG="$data/<<someLog>>.log"
#Creating log file if it does not exist
touch $LOG
echo "Script Started" >> $LOG
echo `date` >> $LOG
echo "Data : $data" (This is coming from the properties file & contains path to were this script is kept)
##############################################################
# Constructing the File Name (File with Date appended)
##############################################################
curDate=`(date +'%Y%m%d_%H%M%S')`
fileName="data_$curDate.csv"
FILE="$data/$fileName" (fully qualified file name)
echo "Path of File being created : $FILE" >> $LOG
sqlplus -s $conn <<EOF
SET PAGESIZE 50000
SET COLSEP ","
SET LINESIZE 32767
SET FEEDBACK OFF
SPOOL $FILE
SELECT * FROM <<TABLENAME>>;
SPOOL OFF
EXIT
EOF
`chmod 777 $FILE`
##################################################
# FTP the data file to a specific path
##################################################
DEST_PATH = $data
echo $DEST_PATH
echo "Destination where the file has to be transferred --> $DEST_PATH" >> $LOG
echo "" >> $LOG
echo "Performing FTP ..." >> $LOG
FTP=`scp $FILE $DEST_PATH`