how to copy whole directories using FTP commands - ftp

Anyone know how to put whole directories from local to another server using FTP command?
i had use mput , but it just transfer file only.
cd /images_temp --> ws_ftp virtual folder name
mput *.IMG --> just transfer multiple file
anyone can teach me what command i need to use to transfer whole directories?
thanks

You can use mput * or mget *. Confirm with a rather than y. You can change the prompting behavior using the prompt command. You will find more information in the manual page. In a unix environment, man ftp

You can iterate and decent into directories and use mput *.IMG but that would probably inefficient. Consider using ncftpput where you can upload the directory remotely with just one line.

Related

Bash script for recursive directory listing on FTP server without -R

There are multiple folders with subfolders and image files on the FTP server. The -R is disabled. I need to dump the recursive directory listing with the path name in a text file. The logic I have till now is that, traverse in each folder, check the folder name if it consists of '.' to verify it as a file or a folder, if its a folder, go in and check for subfolders or files and list them. Since I cannot go with the -R, I have to go with a function to perform traverse each folder.
#!/bin/sh
ftp_host='1.1.1.1'
userName='uName'
ftp -in <<EOF
open $ftp_host
user $userName
recurList() {
path=`pwd`
level=()
for entry in `ls`
do
`cwd`
close
bye
EOF
I am stuck with the argument for the for loop!
Sorry to see you didn't get any replies yet. I think the reason may be that Bash isn't a good way to solve this problem, since it requires interacting with the FTP client, i.e. sending commands and reading responses. Bash is no good at that sort of thing. So there is no easy answer other than "don't use Bash".
I suggest you look at two other tools.
Firstly, you may be able to get the information you want using http://curlftpfs.sourceforge.net/. If you mount the FTP server using curlftpfs, then you can use the find command to dump the directory structure. This is the easiest option... if it works!
Alternatively, you could write a program using Python with the ftplib module: https://docs.python.org/2/library/ftplib.html. The module allows you to interact with the FTP server through API calls.

In FTP, how do I copy a remote file to other directories

Using FTP commands I want to upload a large file once and then copy that file to many directories on the remote FTP server. All the copy commands seems to relate to copying from local to remote or the other way around.
Is there an FTP command to copy remote to remote?
are you trying to move the file? if yes, you can do it using rename command to move the file, as for copy i guess you still have to do the the get,send from local-remote way.
as for move command should be something like this
rename /oldpath/file2move.txt /newpath/file2move.txt
Basically just rename your file path that is infront of the file that you wish to move.
As far as I know, there is no such command available in FTP protocol. There are some extensions to SFTP protocol to do this (and, having SSH access, you can issue cp commands), but SFTP is not an FTP.

Batch download zips from ftp

Good evening.
Can You help me please with some batch file?
I have an ftp, where in root directory located few randomly named zip archives.
So i need to download that archives to local D:\temp
I know, how to do it via ftp.exe, but only for one file, witch name i know:
file: save.bat
ftp -s:1.txt
file: 1.txt
open myftp.com
123login
321pass
prompt
binary
hash
get file.zip D:\test\12.zip
bye
Maybe u can tell me how to download all * zip archives on ftp in loop?
Thanks!
You can use the mget command to download multiple files through ftp. This also supports wildcards.
You can simply use:
mget *.zip

Is it possible to copy files through ftp connection?

I use the following code to put a file from my local machine to a remote machine:
open abc
a
b
lcd C:\Interfaces\KGR-ARV\XML
ascii
prompt
prompt
cd /usr/qkreditnethome/interface/temp
put C:\Interfaces\KGR-ARV\XML\*KGRRequest*QUA.XML
Y
quit
bye
Is there a way, using a ftp command, to copy the file from /usr/qkreditnethome/interface/temp to /usr/qkreditnethome/interface/temp2 ?
Thanks in advance!
There is no copy command in ftp. You will have to GET the file and PUT it where you want.
Depending on the OS you can take some third-party software which mounts the remote FTP as a part of the local filesystem, and then use regular system copy routines.

Is there a way of listing the contents of the local directory in ftp?

lcd changes local directories.
ls lists files on remote directory.
What I would like is lls, to list files on local directory.
Is this possible?
I know I can always open another terminal to do this, but I'm lazy!
Yes:
!dir
The ! tells the client to run a local shell command. Tested this using both the Windows and Fedora default ftp clients. Note that the actual command may depend upon your OS, for example !ls may be necessary on other versions of Unix/Linux.
For what it's worth, the ! command is listed in the ftp client's help system:
ftp> help !
! escape to the shell
To list files locally use following command
!dir
Or use following command
!ls
Note: ! means locally not the remote.
lcd is working but !cd will not work and lpwd is not working but !pwd is working.

Resources