Wednesday, 15 April 2015

csv - Shell Script to get data from database | put it into file | ftp to another path/server -



csv - Shell Script to get data from database | put it into file | ftp to another path/server -

i've been writing shell script info database, set csv file , transfer csv file location.

as location can server i'm using scp (secure copy). i'm getting next error :

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

following script i've coded far :

#!/usr/bin/bash #import properties files . <<propertyfilepath>>.properties ############################################################## # initializing variables ############################################################## #user_cmd=`who i` #user=`echo $user_cmd|tr -s " "| cutting -d " " -f1` #making log file in user home directory log="$data/<<somelog>>.log" #creating log file if not exist touch $log echo "script started" >> $log echo `date` >> $log echo "data : $data" (this coming properties file & contains path script kept) ############################################################## # constructing file name (file 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 beingness created : $file" >> $log sqlplus -s $conn <<eof set pagesize 50000 set colsep "," set linesize 32767 set feedback off spool $file select * <<tablename>>; spool off exit eof `chmod 777 $file` ################################################## # ftp info file specific path ################################################## dest_path = $data echo $dest_path echo "destination file has transferred --> $dest_path" >> $log echo "" >> $log echo "performing ftp ..." >> $log ftp=`scp $file $dest_path`

shell csv ftp sqlplus

No comments:

Post a Comment