ftp - check if file on remote exists (skip overriding)
Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
ftp - check if file on remote exists (skip overriding)
Hello,
I have a script that uploads a file from local to remote place using ftp. The problem is that, if on remote host there is a file called the same as the one I want to upload, the ftp program overrides that file. But I don't want to override nothing (even if the remote file is older, smaller or whatever).
The problem is that I can't test if a file exist on remote (doing [ filename ]) because ftp only allows me limited commands (like ls, mkdir, cd, etc.)
So, how can I check if the file i want to upload already exists, so I can skip overriding ?
Notes :
- Using sunique feature isn't a solution. I don't want to copy nothing if it's there already.
- Maybe using other ftp programs might help, but what programs ?
I've tried lftp too. But it too doesn't have the option of testing the existence of a file prior to uploading(or I haven't figured out).
"Why dont you try "getting" the file first, if its successful remove it locally, else upload." -> I've toughed that , but like a last resort, I am looking for a more elegant solution. What if the file has 4GB ? No, this will be the last solution.
Hey ghostdog74, it seems this is good. But I have a question : how to specify the whole path of the file on the remote ? E.g.: I want to check to see if /httpdocs/sounds/cool.wav is there. How will the code change ?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.