Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 12-14-2011, 01:37 AM   #1
LQ Newbie
Registered: Dec 2011
Posts: 9

Rep: Reputation: Disabled
FTP to windows

Dear All,

I am having a cron job which will take my Oracle DB export every two hrs and it will convert in a zip format which is working fine. Now i need to ftp this zip to a windows machine twice a day, say noon time and end of the day and i need only latest two zip file (distinct name) to ftp on windows machine

-rw-r----- 1 oracle oinstall 343887693 Dec 13 17:25 TESTV1_T13-12-2011-17-24.DMP.gz
-rw-r----- 1 oracle asmadmin 1524719616 Dec 13 18:24 TESTV1_T13-12-2011-18-23.DMP.gz
-rw-r----- 1 oracle asmadmin 1524752384 Dec 14 10:01 TESTV1_T14-12-2011-10-00.DMP.gz

-rw-r----- 1 oracle oinstall 90459849 Dec 13 16:20 TESTV2_T13-12-2011-16-19.DMP.gz
-rw-r----- 1 oracle oinstall 90456593 Dec 13 17:11 TESTV2_T13-12-2011-17-10.DMP.gz
-rw-r----- 1 oracle oinstall 90459898 Dec 13 17:24 TESTV2_T13-12-2011-17-24.DMP.gz

ftp -i -n $HOST <<EOF
user ${USER} ${PASSWD}
mput *.gz

With this it is taking all the zip from the folder.
I need these two latest files.


Any help on this is highly appreciated
Thanks in advance
Old 12-14-2011, 05:55 AM   #2
Registered: Jun 2007
Distribution: Fedora, RHEL, Centos
Posts: 294

Rep: Reputation: 54
to find the last two files accessed in a directory, I would use
ls -tr /path/to/directory/ |tail -n 2
So you could use that in something like:
for z in `ls -tr /path/to/directory/*.gz |tail -n 2`; do 
ftp -i -n $HOST <<EOF
user ${USER} ${PASSWD}
mput $z


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Automate FTP / Scripting FTP Transfers files from linux to windows m/c ashishshukla Programming 5 05-26-2016 10:10 AM
FTP configuring with windows splinux Linux - Server 1 08-02-2011 06:13 AM
Fedora 10 install via Windows XP filezilla ftp server; ftp Url error in kickstart O(V)eGA_l2el) Fedora 2 09-28-2009 10:40 AM
linux to windows ( ftp)!! justsimran Linux - General 3 04-02-2007 08:58 PM
autmated ftp from windows 2k spyghost Linux - Networking 7 07-14-2003 05:13 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:32 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration