LinuxQuestions.org
Help answer threads with 0 replies.
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 11-18-2015, 07:25 AM   #1
ashi.srma1986
LQ Newbie
 
Registered: Oct 2015
Posts: 5

Rep: Reputation: Disabled
synchronize ftp folder


hi there. my name is ashish and i am new here.

i am trying to synchronize a folder on a ftp server. but its not working. i was trying this with crontab. is there any other easy way to to do this.

many thanks
 
Old 11-18-2015, 07:59 AM   #2
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by ashi.srma1986 View Post
hi there. my name is ashish and i am new here.

i am trying to synchronize a folder on a ftp server. but its not working. i was trying this with crontab. is there any other easy way to to do this.
The usual tool to synchronize folders is rsync. cron is a tool for doing things repeatedly.

Can you be a bit more precise? For example, from where to where do you want to synchronize the folder. You mention crontab; what commands did you add to crontab? And what do you mean that it doesn't work; are there error messages?
 
Old 11-18-2015, 08:19 AM   #3
ashi.srma1986
LQ Newbie
 
Registered: Oct 2015
Posts: 5

Original Poster
Rep: Reputation: Disabled
#!/bin/ksh

sdir="/send/"
filename="*"
hostname="10.10.78.60"
username="xyz"
password="zxy"

ftp -in $10.10.78.60<<EOF
quote USER $xyz
quote PASS $zxy

binary
cd $sdir
get $filename
lcd $/pdf/
get $otherfilename
quit
EOF


i wrote this script. which i copied from a forum. but its not working. but i found that this script is for copying samename files from a folder and i want to synchronize a specific folder. for download and upload. we have different kind of files from our ftp server like jpg xls or pdf. please guide me what to do.

with regards
Ashish

Last edited by ashi.srma1986; 11-18-2015 at 08:21 AM.
 
Old 11-18-2015, 09:03 AM   #4
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by ashi.srma1986 View Post
#!/bin/ksh
I recommend bash instead of ksh

Quote:
Originally Posted by ashi.srma1986 View Post
ftp -in $10.10.78.60<<EOF
I believe you want to say -in $hostname.

Quote:
Originally Posted by ashi.srma1986 View Post
get $filename
If ist's more than one file, use mget. Actually, I would simply say mget \* instead of using a variable here.

Quote:
Originally Posted by ashi.srma1986 View Post
lcd $/pdf/
This looks syntactically incorrect. I think you mean lcd /pdf.

Quote:
Originally Posted by ashi.srma1986 View Post
get $otherfilename
Have you initialized this variable?

Quote:
Originally Posted by ashi.srma1986 View Post
i wrote this script. which i copied from a forum. but its not working. but i found that this script is for copying samename files from a folder and i want to synchronize a specific folder. for download and upload. we have different kind of files from our ftp server like jpg xls or pdf. please guide me what to do.
I don't understand this last paragraph. What do you mean with "samename files"? mget * copies all files in a folder.
 
Old 11-18-2015, 09:15 AM   #5
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,661

Rep: Reputation: Disabled
Why not use wget? It would be an oneliner with wget.
 
1 members found this post helpful.
Old 11-18-2015, 09:19 AM   #6
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by Emerson View Post
Why not use wget? It would be an oneliner with wget.
Truer words have never been spoken.
Or use rsync (I like to have the last word).
 
Old 11-19-2015, 05:54 AM   #7
ashi.srma1986
LQ Newbie
 
Registered: Oct 2015
Posts: 5

Original Poster
Rep: Reputation: Disabled
hi there... i have problem to synchronize a local folder with remote ftp folder. i have configured a crontab entry. which is synchronizing my local folder with remote folder. but i want to synchronize my remote folder/files into my local folder.

#!/bin/bash
HOST='10.7.3.184'
USER='vm'
PASS='vm'
SOURCEFOLDER='/disk1/ftp'
TARGETFOLDER='/test'

lftp -f "
open $HOST
user $USER $PASS
lcd $SOURCEFOLDER
cd $TARGETFOLDER
mirror --reverse --delete --verbose $SOURCEFOLDER $TARGETFOLDER
bye
"


Many thanks.
 
Old 11-19-2015, 06:01 AM   #8
ashi.srma1986
LQ Newbie
 
Registered: Oct 2015
Posts: 5

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Emerson View Post
Why not use wget? It would be an oneliner with wget.
Sir i work with a company where we have to download files from ftp server. its newsprint company so time means a lot to us. now we need a person to keep looking into ftp folder. i want only that when someone put something into our ftp folder then the file start downloading by itself into my local drive but the below script is doing reverse. this script deleting the file on remote computer.

#!/bin/bash
HOST='10.7.3.184'
USER='vm'
PASS='vm'
SOURCEFOLDER='/disk1/ftp'
TARGETFOLDER='/test'

lftp -f "
open $HOST
user $USER $PASS
lcd $SOURCEFOLDER
cd $TARGETFOLDER
mirror --reverse --delete --verbose $SOURCEFOLDER $TARGETFOLDER
bye
"

Many thanks
 
Old 11-19-2015, 08:32 AM   #9
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,634

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by ashi.srma1986 View Post
Sir i work with a company where we have to download files from ftp server. its newsprint company so time means a lot to us. now we need a person to keep looking into ftp folder. i want only that when someone put something into our ftp folder then the file start downloading by itself into my local drive but the below script is doing reverse. this script deleting the file on remote computer.
You need to realize that this is a VOLUNTEER forum...this is NOT URGENT for us in any way. If you are employed by a company to perform a job, then YOU need to be in a hurry, not us. Telling us "time means a lot to us", doesn't get us to help you quicker. Also, if you're in such a hurry, you may want to consider actually posting WHAT PROBLEMS you're having, other than just saying "i have a problem", or "its not working". Those give us NO details as to what error(s)/message(s) you're seeing. If it's REALLY urgent for you, then HIRE SOMEONE to do this. You re-posted a question after SEVEN MINUTES, asking for help. We don't just sit here and wait for you to post.
Quote:
Code:
#!/bin/bash
HOST='10.7.3.184'
USER='vm'
PASS='vm'
SOURCEFOLDER='/disk1/ftp'
TARGETFOLDER='/test'

lftp -f "
open $HOST
user $USER $PASS
lcd $SOURCEFOLDER
cd $TARGETFOLDER
mirror --reverse --delete --verbose $SOURCEFOLDER $TARGETFOLDER 
bye
"
Again, as has been suggested several times now, why aren't you using rsync or wget?? Those are the best tools for the job. And the very first hit in Google for "linux bash script to automate ftp transfers" is:
https://www.linux.com/community/blog...ersonal/386522

...complete with a working example. Change the commands to get the files and delete them. Since time means a lot to you, doing research on your own is a great place to start.
 
1 members found this post helpful.
  


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
How to synchronize the contacts folder in Thunderbird? xpucto Linux - Newbie 2 04-01-2011 06:15 AM
[SOLVED] Renaming a folder which is default folder for FTP account anon091 Linux - Newbie 6 02-11-2011 09:30 AM
files not visible in ftp site (but present in the /var/ftp/folder of the server) dongrila Linux - Newbie 2 12-23-2007 10:09 PM
Synchronize FTP with local folder KrzysieQ Linux - Software 0 09-10-2007 06:22 AM
evolution consuming 100% CPU to synchronize folder maxfacta Linux - Software 1 08-23-2007 10:35 PM

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

All times are GMT -5. The time now is 05:02 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