• Guest, The rules for the P & N subforum have been updated to prohibit "ad hominem" or personal attacks against other posters. See the full details in the post "Politics and News Rules & Guidelines."

Need some FTP help (writing an automated .bat file)

TheNinja

Lifer
Jan 22, 2003
12,207
1
0
So I'm trying to write a simple batch file (.bat) that will simply run from the desktop when clicked. All it has to do is go to a site and download a file (it will be the same file name and location everytime). And then disconnect when it's done. Sounds easy? Well it might be if you are smarter than me.

Example:

ftp
open
yoyoma.me.com
user1
password
get <file>
logout
quit
close
 

FoBoT

No Lifer
Apr 30, 2001
63,089
12
76
fobot.com
so your .txt file would be like this

open yoyoma.me.com
user1
password
cd <to the dir needed>
lcd C:
bin
hash
prompt
get <file>
quit
then just put "ftp -s:<filename>.txt " into the .bat file with <filename.txt> being the name of the above .txt file
 

TheNinja

Lifer
Jan 22, 2003
12,207
1
0
FoBot you are my new HERO!!! seriously, thank you so much for that. It's exactly what I wanted. I totally forgot I had to call it from a batch file and point it to a .txt "script".

Let me know if there is anything I can do for ya.

btw:
for educational purposed I want to break down each line

open yoyoma.me.com ---- obviously open to the ftp site
user1 ---- username
password ---- password
cd <to the dir needed> ---- cd to proper directory
lcd C: ---- I'm guessing it sets the local directory to download to
bin ---- don't know why it's needed
hash ---- don't know why it's needed
prompt ---- don't know why it's needed
get <file> ---- downloading the file
quit ---- quitting application
 

FoBoT

No Lifer
Apr 30, 2001
63,089
12
76
fobot.com
lcd is to set the local directory, that is where you want the file to land on your hard drive
bin is to make it a binary download vs. ascii for text - this is important depending on the file you want to get. if the file is an .exe or .jpg, etc, then you need to make sure you are in binary mode
i don't know what hash is either
not sure why prompt is good either

i copied this from a symantec script they have linked in their knowledge base
 

Aves

Lifer
Feb 7, 2001
12,228
25
101
Originally posted by: FoBoT
i don't know what hash is either
Hash forces the program to output a series of #s, without it you don't get any output until the download is complete.
 

FoBoT

No Lifer
Apr 30, 2001
63,089
12
76
fobot.com
Originally posted by: SUOrangeman
wget can also be your friend.
i use wget for http

but i had problems using it with ftp and our proxy. the readme lists some switches for proxy use, but i failed to get it to work
 

ASK THE COMMUNITY