1847287 Members
2643 Online
110263 Solutions
New Discussion

Re: ftp help

 
corpit
New Member

ftp help

i wanted to copy all files in ftpserver to my webserver . and also i wanted to delete only those files which are copied .

6 REPLIES 6
BONNAFOUS Jean Marc
Trusted Contributor

Re: ftp help

Hi,

Are ftpserver and webserver Unix box?
Do you want to use manual transfert or automatic transfert?

If webserver is Unix box and use automatic transfert:

from webserver do:
ftp -i -n < "ftpfilename"

where filename is a file with ftp commands:

open ftpserver
users USERS PASSWD
binary
cd
mget *
mdelete *
bye

If you want to use manual command use
ftp ftpserver, then give username and password and use command like before.

If your webserver is a Windows box you can instal and use a graphic ftp client product (more are free) on your Windows box. It's easier to use.

Rgds
JMB
Si vous ne faites jamais de bétises, c'est que vous ne faites rien de difficile. Et ça c'est une grosse bétise.
Muthukumar_5
Honored Contributor

Re: ftp help

You can do it with ftp easily as,

mdelete
mput or mget

If you are going to start on webserver then,

ftp -n
ftp> open account passwd
ftp> mget *
you have to give y to get every files
ftp> mdelete *
you have to give y to all files.

If you feel it is getting time then,

come r* commands.

On webserver

IF you are trying as root then,

echo + > /.rhosts
chmod 400 /.rhosts

Make the file on ftpserver too.

Now do as,

cd
rcp webserver:/dir/* .

It will copy at once then,

remsh webserver -l root -n "/usr/bin/rm -rf /directory/"

It is over now.

Regards
Muthu



Easy to suggest when don't know about the problem!
Dave La Mar
Honored Contributor

Re: ftp help

Corpit -
ftp -n -v << endl >> log_file
open server name
user user_name user_password
prompt
lcd $Local_directory
cd $Remote_directory
mput XX*
mput XX*
mput ZZ*
quit
endl

1. log_file will have the information on the data sent.
2. Use the log_file to build your delete list.
3. Prompt toggles off the prompt on each put.

Things to note:
a. Username and Userpassword should never be hard coded. Look at .netrc for you unix box.
b. The log_file assumes you are sending from the box you wish to delete from.
c. If b. is reversed one would do the mget and wold have to build the read of the log_file to feed the ftp delete command.

Best of luck.

Regards,

dl
"I'm not dumb. I just have a command of thoroughly useless information."
corpit
New Member

Re: ftp help

i can't use mget *.* and mdelete *.* , because ,
1. ftp server keeps on getting files from diffrent servers , and also my web server keeps on downloading files from ftp server . so if i say mget *.* , after that mdelete *.*, there may be chances of deleting files which are not yet downloded .
what i want is , web server downloads files from FTP server , we should maintain a log and from that log , only downloaded files should be deleted from ftp server.
is it possible to use any loop in ftp ? look at my sample code , and pls advice me .


#bin/ksh

#local directory of webserver.
cd /tmptbs

ftp -inv servername<user USERNAME PASSWORD

#remote direcotry of ftp server
cd /corp/in
dir *.* remlist.tmp
mget *.*
for VAR in <do
echo dele $VAR
EOT
bye
EOF

Dave La Mar
Honored Contributor

Re: ftp help

No loop type logic within the ftp job.
As I noted before, the log_file would have the list of files eligible for deletion which could be used for your delete command in ftp.

Best regards,

dl
"I'm not dumb. I just have a command of thoroughly useless information."
Doug Lamoureux_2
Valued Contributor

Re: ftp help

Have you looked at using rsync or rdist?