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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBS scripted FTP

Status
Not open for further replies.

gurner

Technical User
Joined
Feb 13, 2002
Messages
522
Location
US
I'm try to make this a wild card download from the NAI FTP site, FTP Batch scripting is an alternative, but i have started this (with reference help) and would like to see it finished.

Any ideas?

The only way it presently works is if i specify a particular file name on 'strDest' and 'strSourceFile'

This is no good for changing contents, by the time a new file name is added to the script each time you might as well have manually downloaded it.

------------------------------------------------

'variables
Dim objFTP
Dim strDest, strSource, strSourceFile

'filename and path properties
strDest="C:\ftp\*.*"
strSource="pub\antivirus\datfiles\4.x\"
strSourceFile="*.*"

'object properties
Set objFTP=CreateObject("Mabry.FTPXObj")
objFTP.Blocking=True
objFTP.Host="ftp.nai.com"
objFTP.LogonName="anonymous"
objFTP.LogonPassword="pass"
objFTP.SrcFilename=strSourceFile
objFTP.DstFilename=strDest
objFTP.Directory=strSource

'execute
objFTP.Connect
objFTP.ChangeDir
objFTP.GetFile
objFTP.Disconnect

Set objFTP=Nothing

Wscript.Quit

----------------------------------------

Cheers

Gurner

What is Divine Paradox?

 
Hello Gurner,

I would then loop through the source.
Code:
'variables
Dim objFTP
Dim strDest, strSource, strSourceFile

'filename and path properties
strSource="pub\antivirus\datfiles\4.x\"
'strSourceFile="*.*"
strDest="C:\ftp\"
set fso=createobject("scripting.filesystemobject")
set cFiles=fso.getfolder(strSource).files

'object properties
Set objFTP=CreateObject("Mabry.FTPXObj")
with objFTP
    .Blocking=True
    .Host="ftp.nai.com"
    .LogonName="anonymous"
    .LogonPassword="pass"

    for each oFile in cFiles
        strSourceFile=oFile.name
        .SrcFilename=strSource & strSourceFile
        .DstFilename=strDest & strSourceFile
        .Directory=strSource

        'execute
        .Connect
        .ChangeDir
        .GetFile
        .Disconnect
    next
wend

Set objFTP=Nothing
set cFiles=nothing
set fso=nothing

Wscript.Quit
regards - tsuji
 
bet you could tell i'm not a developer. ha!

just rudimentary scripting is as far as i can go.

(more of an Admin/Network type)

Been finding this scripting lark very useful

Cheers

Gurner

What is Divine Paradox?

 
You can be, in near to no time.

- tsuji
 
Or you could write an ftp answer file with all the commands line by line in order the same as you would in you connected via a command prompt. Doing it this way, you would use the "mget *.*" ftp command after you cd to the correct directory.

You initiate the xfer in the vbs script with the "run" method of Windows Script host:

Code:
Dim WshShell
Set WshShell = CreateObject("WScript.Shell")
WshShell.run ("FTP -s:C:\ftpanswerfile.txt",1)
Set WshShell = nothing
 
I think its much easier with de ftp.exe from windows:

---save this to "download.ftp" --
open ftp.nai.com
mail@mail.bla
cd C:/temp
cd /pub/antivirus/datfiles/4.x
binary
prompt
mget *.zip
mget *.exe
mget *.upd
mget *.txt
mget *.ini
bye
---------

start in a cmd ftp -s:download.ftp



greets

 
yeah but you dont learn as much that way, readthenews ;-)
 
Hi all,
Could anyone tell me what Mabry.FTPXObj is?
Isn't it a paying ActiveX object?
Is there a way to do some ftp transfers without this object?
Thanks for help, any help will be appreciated.
Bye gap692b.
 
Mabry.FTPXObj is an object you pay for, it was just one alternative i was trying to see if i could do this.

I'd also like to know if there is a generic way of doing it

Gurner

What is Divine Paradox?

 
A generic way of doing what?? an FTP transfer?
If this is what you mean,well...
Your vbscript file could create dynamically a file containing ftp commands and then run it thanks to the shell object (as it is mentionned above...) .
Don't know if it was what you were wondering for?
bye,gap692b.
 
I don't know enough about it to go into a lot of detail, but i was hoping to achieve it using a built in object? rather than the Mabry.FTPObj i found on a site.

Cheers

Gurner

What is Divine Paradox?

 
If you want to pay to use a built in object,do it otherwise if you want a script which does what I told you just ask me,give me your mail and I will send it to you if you desire!!
bye,gap692b
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top