LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 01-06-2016, 02:13 AM   #1
hruday
Member
 
Registered: Jun 2015
Posts: 88

Rep: Reputation: Disabled
Using ftp to transfer files from one server to another


I am using FTP to login into remote server to copy files

#!/bin/sh

DUMPS=/root/exp/
TMP=/root/tmp

find $DUMPS/*.sql.zip -type f -mtime +15 -exec cp {} $TMP \;

cd $TMP

# FTP Login

HOST=ipaddr
USER=usrname
PASS=passwrd123
REM_DIR=/home/bkpdir

for f in *; // the second time when i run the script
do
echo "Uploading file via FTP:" $f

ftp -in $HOST <<EOF

quote USER $USER
quote PASS $PASS

cd $REM_DIR
put $f
bye
EOF

done



It works fine but the problem i have to run this daily to copy files which are 15 days old in dumps dir.

There are a lot of files which are 15 days old, say some 20 files but when i run the script the next day i'll have to copy only one file which is 15 days old.

how can i achieve this?
how should i avoid files which are already copied?

Last edited by hruday; 01-06-2016 at 02:46 AM.
 
Old 01-06-2016, 02:41 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,838

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
duplicate of https://www.linuxquestions.org/quest...ct-4175562924/
 
Old 01-06-2016, 02:47 AM   #3
hruday
Member
 
Registered: Jun 2015
Posts: 88

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
hi pan64
as expect was not working for me I created script using ftp.
 
Old 01-06-2016, 10:13 AM   #4
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
Quote:
Originally Posted by hruday View Post
There are a lot of files which are 15 days old, say some 20 files but when i run the script the next day i'll have to copy only one file which is 15 days old.

how can i achieve this?
how should i avoid files which are already copied?
Use keys or expect with rsync. I posted a complete and working example of using expect for this purpose in your other thread, but I didn't see any response to that post indicating problems or questions. Did you even try it?
 
  


Reply



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
transfer files created on last day of month to ftp server hruday Linux - Newbie 34 12-07-2015 07:17 AM
file transfer program in c using FTP client and FTP server renuaseri Linux - Newbie 2 01-29-2011 05:49 AM
ftp : need to transfer 2.5terrabyte(huge number of files), good ftp program ? ghoulsblade Linux - Software 8 10-29-2009 03:59 AM
Help needed to transfer list of files to FTP server, to different folders amazon Programming 1 06-26-2009 01:12 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:55 PM.

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