-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Inner file is run as many times as there are files by the outer file. This is because Inner file can only rename one file at a time on SFTP due to limitations of SFTP protocol
- Loading branch information
kowalsk
authored and
kowalsk
committed
Jan 15, 2016
1 parent
62663e6
commit 2c88ff4
Showing
3 changed files
with
32 additions
and
18 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/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 |