-
-
Save bmangesh/04de0cb1a5787e887f7b to your computer and use it in GitHub Desktop.
Fetch latest timestamp file from ftp server e.g abcdDDMMYY.txt
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
#!/bin/bash | |
#Author: MANGESHKUMAR B BHARSAKLE | |
#PROBLEM:How to download latest timestamp file from FTP remote SERVER to local | |
if [ -f tempfile ] | |
then | |
rm -rf tempfile | |
fi | |
ftp -n 192.168.127.151 >tempfile <<EOF | |
user ftp ftp | |
cd pub | |
ls -t | |
quit | |
EOF | |
var=`cat tempfile | head -1 | tr -s ":" | cut -d ":" -f2 | cut -d " " -f2` | |
echo "File Name $var" | |
ftp -n 192.168.127.151 <<EOF | |
user ftp ftp | |
cd pub | |
ls -t | |
get $var | |
quit | |
EOF | |
if [ -e $var ] | |
then | |
echo "File Found" | |
else | |
echo "File Not found" | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment