Discussion:
FTP files by reading from the text file.
(too old to reply)
Abhijat
2010-09-13 17:37:50 UTC
Permalink
Hi Group,

Here is my situation:
I have a dos script which downloads all the files from an ftp server
and once the download is complete, it deletes the file at the ftp
server. Files are continuously posted on the server and my script runs
every 30 minutes and does the same thing.

Here is my Question:
I have to now modify this script such that this operation of
downloading and deleting happens only on a few files. The nomenclature
of these files will be stored in a master file (say, master_file.txt),
one below the other. So, I understand I need to run a loop over all
the names in the master_file.txt and do the same thing. However, I am
unable to do so and seek the help of you experts.

My earlier code was:

@ECHO OFF
S:
cd S:\app\inbound\vendors
ftp -v -n -i -s:C:\BATCH\ftpscript1.txt

C:
:end

the ftpscript1.txt was

open <ftpproxy>
user ftp_proxy_user_name ftp_proxy_pswd
user ***@ftp_url ftp_pswd
mget *.*
mdelete *.*
quit

the master_list.txt can be
abcd
qwer
zxcv
asdf
poiu
---
----

Thanks very much!

~Abhijat
Auric__
2010-09-14 15:12:19 UTC
Permalink
Post by Abhijat
I have a dos script which downloads all the files from an ftp server
and once the download is complete, it deletes the file at the ftp
server. Files are continuously posted on the server and my script runs
every 30 minutes and does the same thing.
I have to now modify this script such that this operation of
downloading and deleting happens only on a few files. The nomenclature
of these files will be stored in a master file (say, master_file.txt),
one below the other. So, I understand I need to run a loop over all
the names in the master_file.txt and do the same thing. However, I am
unable to do so and seek the help of you experts.
(Follow-up set to alt.msdos.batch.nt.)

microsoft.public.basic.dos is supposed to be about the BASIC programming
language under DOS. For future batch questions, ask in alt.msdos.batch.nt;
the *real* batch experts are there.

Having said that, I'm not a batch "expert" by any definition of the word,
but this *should* work. In the "for" line, "master_list.txt" needs to be
the full path to wherever it is, unless it's in "S:\app\inbound\vendors".

-----begin ftp-script.cmd-----
@ECHO OFF
S:
cd S:\app\inbound\vendors
echo open ftpproxy>ftpscript1.txt
echo user ftp_proxy_user_name ftp_proxy_pswd>>ftpscript1.txt
echo user ***@ftp_url ftp_pswd>>ftpscript1.txt
for /f %%x in ('type master_list.txt') do (
echo get %%x>>ftpscript1.txt
echo delete %%x>>ftpscript1.txt
)
echo quit>>ftpscript1.txt
ftp -v -n -i -s:ftpscript1.txt
-----end ftp-script.cmd-----

To test this, remove the actual "ftp" line (delete it from the file), run
it, and examine ftpscript1.txt to make sure it's correct. If it looks
kosher, add the ftp line back in. (Works ok on my system, but I don't have
your system to test against.)
--
There are multiple sides to every situation,
just as there are two sides (and an edge) to every coin.
Loading...