Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBSCRIPT TO FTP

Status
Not open for further replies.

craizie11

MIS
Mar 18, 2004
14
0
0
US
does anyone have a VBSCRIPt that will connect to a FTP site and download all the files (including subdirectories) in the directory.

For Example my ftp site is: ftp.injoy.com
username: user
password: pass

then i want to change to directory /webapps

and then download all the files (including all the subdirectories in /webapps) into my c:\webapps directory

I was using a dos batch file with the mget command, however mget doesn't pull the subdirectories.
And i need to be able to get the subdirectories.
 
No, but I have the opposite. I have one that you put into your sendto folder so that when you right click a file you get a sendto FTP site option.
 
MGET won't do the subs. To get multiple files from multiple subdir's, write an answer file. Use the same commands as you would enter at the CLI in a txt doc, line by line. Then run the answer file against the Wscript.Shell run method like so (Assuming the txt was in C:\):

Code:
Set ObjShell = CreateObject(Wscript.Shell)

ObjShell.Run ("FTP.EXE -s:C:\Answerfile.txt")

Set up the destination folders, and use "lcd" in the answer file to change dest dir's.

And don't forget to release the instanstiated objects with a "Set objShell = nothing" to prevent memory leaks. (Just a personal rule of thumb of mine)

Hope that helps.
 
Narizz,

Thanks for the advice...but what exactly am i putting in the answerfile.txt that'll allow me to pull the subdirectories? Just the dos commands for ftp?
 
I think ncftp will do subs. Can't remember for sure.
 
Yes, throw a CD in between MGET statements (and an lcd command to change the local current dir) and walk the subdir's manually. You answer file will look something like this:

Code:
username
password
binary
lcd C:mget *.zip 
lcd C:\Folder1
cd folder1
mget *.zip
lcd C:\folder2
cd folder2
ascii
mget *.ini
bye

And kick the ftp session off bye the example in my first post in this thread.

Hope that helps you.
 
Oops, I forgot the VERY FIRST LINE in the answer should be the connection, like:

open ftp.domain.com

Sorry about that.
 
Narizz28,

Thanks for the advice. What i'm looking for is a method for the script to automatically detect the directories and then pull the files from there. More of a dynamic script (VBSCRIPT or DOS Batch), rather then me specifying the directories to download. I don't know if there exists such a method, but if anyone knows please let me know.

Thanks again.
 
you could do it using ncftp. It will give you a dir of the remote directory. You can capture this output parsing it for the subdirs. Then CD into those pull their files and see if any of them have subdirs...etc...etc.
 
This is a question for xmsre:

When you said:
"No, but I have the opposite. I have one that you put into your sendto folder so that when you right click a file you get a sendto FTP site option."

what sendto folder are you talking about? I would like to be able to add some of my own scripts to a right click menu.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top