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 ? Thx, Adrian |
Try lftp.
|
You could give "lftp" program a try.
Why dont you try "getting" the file first, if its successful remove it locally, else upload. |
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. |
Code:
$ result=$(ftp -n localhost<<EOF | awk '/myfile/{print "1"}' |
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 ?
Thx |
All times are GMT -5. The time now is 01:05 AM. |