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!

NEWBIE Question on FTP and VBScript

Status
Not open for further replies.

dshak

Programmer
Oct 8, 2004
2
0
0
US
I'm trying to make a script that will check files in a directory on a website.

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

Dim MySite,filesys, demofolder, fil, filecoll, filist, WScript

'Create a connection object and assign it to the variable

Set MySite = CreateObject("CuteFTPPro.TEConnection")

' Now set each property for the site connection
' You can omit this section to use the default values, but you should at least specify the Host
'The default Protocol is FTP, however SFTP (SSH2), FTPS (SSL), HTTP, and HTTPS can also be used)

MySite.Protocol = "FTP"
MySite.Host = "FTP.HOST.com"

'following lines are optional since the default is anonymous if no login and password are defined

MySite.Login = "LOGIN"
MySite.Password = "PASSWORD"

'if necessary, use the UseProxy method and ProxyInfo or SocksInfo properties to connect through a proxy server

MySite.UseProxy = "BOTH"

'now connect to the site (also called called implicitly when most remote methods are called)

MySite.Connect


'perform some logic to verify that the connection was made successfully

If (Not Cbool(MySite.IsConnected)) Then
MsgBox "Could not connect to: " & MySite.Host & "!"
Quit(1)
End If

'The script will now check to see if the local folder c:\temp exists and will create it if necessary

If (Not (MySite.LocalExists("c:\tempshak"))) Then
MySite.CreateLocalFolder "c:\tempshak"
End If

'Change TE's local working folder to to c:\temp
MySite.LocalFolder = "c:\tempshak"

'Check for existence of remote folder "/merchant/ONEinc/Data"

b = MySite.RemoteExists("/merchant/ONEinc/Data")

If (Not CBool(b)) Then
'Verify existence of remote folder
MsgBox "Remote folder not found!. Please make sure that the Pub folder exists on the remote site"
Quit(1)
End If

'Now download the index file to the local destination folder
MySite.Download "*.order"

'Complete. Show the status of this transfer.
MsgBox "Task done, final status is '" + MySite.Status + "'"

MySite.Disconnect
MySite.Close

'End of sample script. You can save you script and then run it by either selecting it from the Tools > Run Script menu or by double clicking on the script file in Windows


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

What I need to do is on the ftp it needs to check the file extension. IF there is a 0001.axm but NO 0001.order then I dont want to download that file. I want to rename the extension to 0001.err. Also if there is a 0001.axm and a 0001.order then rename the 0001.axm to 0001.done. Please help! I've looked on the internet for hours with no help. Thank YOU!!!

dshak
 
Im also trying to set up a script that does some ftp stuff. I have a script that sleeps and periodically wakes up and copies some files. I need to modify it so that I can ftp those files.

Does anyone have any examples of running ftp using scripting?
 
Have you tried a keyword search in this forum for ftp ?
62 threads at this time ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
that was how i stumbled onto this one... Im working through them now to see if there's one that will work.. Ive tried a couple but am still trying to get one that works...

thanks
 
I have a scriptable FTP object that I wrote a while back because I couldn't find one that worked or wasn't extremely expensive. You can find it on
It supports the following Properties & Methods:


Methods:
--------------------------------------------------------------------------------
Start: Initialize object and set all defaults
Kill: Shutdown (destroy) object
OpenSession: Connect to the server defined by the ServerName property
using the values in the UserName and Password properties.
CloseSession: Close the aforementioned session
GetDirectory: Retrieve the contents of the directory specified by the
RemoteDirectory property. return value is number of files
RetrieveFileNames: Return the found File Names as an array of Strings
RetrieveFileDates: Return the found file dates as an array of Dates
GetFile: Download specified file from RemoteDir to LocalDir
PutFile: Upload specified file from LocalDir to RemoteDir. Takes two
parameters LocalFile and (optional) RemoteFile. If
RemoteFile isnt specified, file is uploaded with the same
name as LocalFile
DeleteFile: Delete file from remote server
CreateRemoteDir: Create a subdirectory under RemoteDir
RemoveRemoteDir: Delete a subdirecory specified by RemoteDir
RenameRemote: Rename a file in RemoteDir

Properties:
--------------------------------------------------------------------------------
NOTE: All property values are string unless otherwise noted.

Title: Set the Title of the window
ServerName: The name of the remote FTP server
UserName: User name to use to connect
Password: Password used to connect. Displayed as a series of *
RemoteDir: Location of files on the remote server
LocalDir: Location of files on the local machine
FileSpec: Filter on requsted files, default is *.*
Visible: (Boolean) Is form visible, default is False.
Mode: (Boolean) True = Binary, False = ASCII
ReplaceExisting: (Boolean) True = Overwrite files if exist, False = dont.

Error Codes:
--------------------------------------------------------------------------------
80040400: You tried to initiate a connection without setting the server name
80040401: You tried to change to a remote directory that did not exist
80040402: You tried to set the local dir to one that did not exist
80040403: You tried to get/put a file, but did not specify a name.
80040404: You tried to download a file that already existed and ReplaceExisting
is set to False
80040405: You tried to get/put a file without calling OpenSession first.
80040406: There was an error setting the remote directory
80040407: There was an error creating a directory on the FTP server
80040408: There was an error removing a directory on the FTP server
 
SeniorGuru,

Thanks for the TIP. Too bad I just finished writing my .vbs work around for a similar issue. HOWEVER, I am still working on a more permanent solution, and would like this file. Problem is, you can't download it from the site you posted. Could you get this corrected, and let us know when we can get this? I'll assume that it's an .OCX file that will require registering.

-SWarrior
 
It is available for download, but you have to register on the site first. It is

It's actually a ActiveX EXE. The installer should register it automatically. If it does not, then just double click on it in Windows Explorer and it will take care of the rest automagically.
 
SeniorGuru,

I had already registered before I posted, but now that I went back to look again, the download IS there, but in a different section. Project Downloads!

Silly me!

-SWarrior
 
Yeah...I've got them separated out because the module I'm using to handle the d/l's doesn't allow restrictions on a per file basis.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top