Unoffical empeg BBS

Quick Links: Empeg FAQ | RioCar.Org | Hijack | BigDisk Builder | jEmplode | emphatic
Repairs: Repairs

Topic Options
#252752 - 27/03/2005 10:16 FTP via windows scripting
Mach
old hand

Registered: 15/07/2002
Posts: 828
Loc: Texas, USA
I'm working on a project for which we built a simple vb utility to do file transfers. Now the plan has changed to include FTP via Windows Scripting. I spent Friday afternoon searching for examples of how to do this but got quickly frustrated. I'm pretty sure that building something would be like re-inventing the wheel as others have to have solved this before. Does anyone know of a site for scripting that I could buy a set of scripts to handle this?

It needs to move files to and from an FTP server while logging transfers. This is all happeing in a Windows XP or 20003 environment.

Top
#252753 - 27/03/2005 11:30 Re: FTP via windows scripting [Re: Mach]
g_attrill
old hand

Registered: 14/04/2002
Posts: 1172
Loc: Hants, UK
Doing it interactively in plain VBScript is probably going to be impossible without some kind of COM object. Looking around, it seems that most people write a temporary file and then execute ftp.exe with the file as the command argument.

If you can use .net then it would be quite a bit easier.

Gareth

Top
#252754 - 27/03/2005 18:30 Re: FTP via windows scripting [Re: g_attrill]
Mach
old hand

Registered: 15/07/2002
Posts: 828
Loc: Texas, USA
I'll likely do the same with ftp.exe. I figured that this would be pretty common. I hate to spend time on it but maybe I'm making more out of it than it actually is. Thanks for the reply.

Top
#252755 - 29/03/2005 10:10 Re: FTP via windows scripting [Re: Mach]
AndrewT
old hand

Registered: 16/02/2002
Posts: 867
Loc: Oxford, UK
I use the Windows Scripting Host under Win2kAS to FTP send/receive files using NCFTP. I chose NCFTP because it handles communication failures gracefully and because it supports lots of command line options.

Here's a part of a .JS script file that I use to send files. Its all very basic but it might get you started if you want to use NCFTP:
Code:

function SendFileByFTP( strFName )
{
var strCMD, oShell, RetValue;

//Build NCFTP command line
strCMD = "\"" + strFtpAppFullPath + "\""; //Full path to FTP prog
strCMD += " -u " + strFtpUserName; //Username
strCMD += " -p " + strFtpPassword; //Password
strCMD += " -P " + strFtpPort; //Remote Port
strCMD += " -t " + intFtpTimeout; //Timeout
strCMD += " -V"; //No progress meter
strCMD += " -r " + intFtpRetryCount; //# Retries
strCMD += " -S .tmp" //Rename after upload hp123456.ord.tmp -> hp123456.ord
strCMD += " -E "; //Regular PORT connection
//strCMD += " -F "; //Use PASV
//strCMD += " -DD "; //Delete local file if successful
if (boolFtpEnableDebug = true) //Check if debug enabled in db
{
strCMD += " -d " + strFtpDebugFilename; //Local debug filename
}
strCMD += " " + strFtpIP; //RemoteHost's IP
strCMD += " " + strFtpDropDir; //Remote dir
strCMD += " " + strFName; //Filename to send

oShell = new ActiveXObject ("WScript.shell");
//oShell.run ("cmd /K CD C:\\temp & " + strCMD,1,true);

//Execute the cmd line, window mode, pause (this) script while running
RetValue = oShell.run (strCMD,1,true);
return( RetValue );

}


Top
#252756 - 29/03/2005 16:09 Re: FTP via windows scripting [Re: AndrewT]
Mach
old hand

Registered: 15/07/2002
Posts: 828
Loc: Texas, USA
Cool, I think I can work with that. Thank you.

Top