ftp a directory to another server from the local server what is the command
Does the directory already exist on the remote box?
Can you use ssh to connect or do you have to use ftp?
This is the best and basically only choice, which preserves file permissions and ownership, command from the source machine:
tar cpf - /some/important/directory | ssh user@destination-machine "tar xpf - -C /some/newdirectory/"
There is no ftp equivalent. And if you cannot log onto the remote box you will have to manually create the directory using the ftp command mkdir, then copy each file over:
cd /path/to/source-directory
HOST='remote-box'
USER='you'
PASSWD='yourpw'
FILE='file.txt'
ftp $HOST <<-EOF
user $USER
$PASSWD
cd /path/to/
mkdir newdirectory
quit
EOF
for fname in *
do
ftp $HOST <<-EOF
user $USER
$PASSWD
cd /path/to/newdirectory
put $fname
quit
EOF
done
1 Like
Thanks...i am new to Unix....I will try the command