从数据库获取数据的Shell脚本|将其放入文件| ftp到另一个路径/服务器

从数据库获取数据的Shell脚本|将其放入文件| ftp到另一个路径/服务器,shell,csv,ftp,sqlplus,Shell,Csv,Ftp,Sqlplus,我一直在编写一个shell脚本,从数据库中获取一些数据,将其放入一个csv文件,然后将该csv文件传输到另一个位置 由于位置可能是另一台服务器,我正在使用scp secure copy。但我得到了以下错误: demo.sh: DEST_PATH: not found usage: scp [-12346BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file] [-l limit] [-o ssh_option] [-P port

我一直在编写一个shell脚本,从数据库中获取一些数据,将其放入一个csv文件,然后将该csv文件传输到另一个位置

由于位置可能是另一台服务器,我正在使用scp secure copy。但我得到了以下错误:

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`

DEST_PATH=$data应该是DEST_PATH=$data。此外,几乎所有的反勾号都是不必要的,除非它们是试图在S.O.上进行格式化的结果。在任何一种情况下,它们都会混淆您的问题,因此最好删除它们并用您当前的代码编辑此问题。这段代码还有很多其他小问题,如果按发布的方式运行,这意味着它永远不会工作,即LOG=$data/.LOG祝你好运。谢谢你删除了空格。其余的代码运行良好。。