From 0ec1bb3591c544f157a0b18104630e62008e9ad4 Mon Sep 17 00:00:00 2001 From: kowalsk Date: Fri, 15 Jan 2016 15:28:59 +0000 Subject: [PATCH] One file version Just combined to one file --- asftp.sh | 19 +++++++++++++++++++ inner.sh | 26 -------------------------- outer.sh | 6 ------ 3 files changed, 19 insertions(+), 32 deletions(-) create mode 100755 asftp.sh delete mode 100755 inner.sh delete mode 100755 outer.sh diff --git a/asftp.sh b/asftp.sh new file mode 100755 index 0000000..748ecc3 --- /dev/null +++ b/asftp.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +for file in `find ftpsource -name \*.csv`; do + +filename=$(basename $file) +echo $filename +mv $file $file.tmp + +sftp USER_NAME@IP_ADDRESS << EOT +cd out +put $file.tmp +rename $filename.tmp $filename +ls -al +bye +EOT + +rm $file.tmp + +done \ No newline at end of file diff --git a/inner.sh b/inner.sh deleted file mode 100755 index d0c48db..0000000 --- a/inner.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash - -#This script uploads one file at a time to SFTP server -#It renames local file first to .tmp -#It then connects, uploads file, renames it back to no .tmp -#It then disconnects and delets the local .tmp file - - -#keeping original name for later step -filename=$(basename $1 .tmp) - -#renaming original local file to FILENAME.tmp to mark it is being processed -mv $1 $1.tmp - - -#connecting to SFTP using username & ssh keys - not passwords -sftp USERNAME@IP_ADDRESS << EOT -cd out -put $1.tmp -rename $filename.tmp $filename -ls -al -bye -EOT - -#removing the original file -rm $1.tmp diff --git a/outer.sh b/outer.sh deleted file mode 100755 index ff459a7..0000000 --- a/outer.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -# this script just runs the "inner.sh" script as many times as there are files in the directory -for file in ftpsource/*.csv; do - ./inner.sh $file -done \ No newline at end of file