Re: wScript.Shell Problems
- From: "Nico VanHaaster" <nvanhaaster@xxxxxxxxxxx>
- Date: 11 Jul 2006 18:13:07 -0700
Guess i should give you all the code. Thanks in advance
'//Start FTP-Files.vbs
Const COMMAND_FTP = "ftp.exe -i -s:"
CONST strHost = "localHose" 'Host Server
CONST strUser = "ftpUsername" 'User Name
CONST strPass = "ftpUserPass" 'Password
CONST strMode = "ascii" 'Mode (ascii/binary)
FTP("DIR")
Function FTP( strCMD, oFile )
Dim objFSO
Dim strFile, objTempFldr, objFile, objRegExp
Dim objShell, WSX, ReturnCode, Output, strLog, strErrorLog
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set oFileFSO = objFSO.OpenTextFile(oFile,2,True)
set objTempFldr = objFSO.GetSpecialFolder( 2 )
strFile = objFSO.GetTempName
strFile = objTempFldr & "\" & left(strFile,Len(strFile)-4) & ".ftp"
if not objFSO.FileExists( strFile ) then objFSO.CreateTextFile(
strFile )
Set objFile = objFSO.OpenTextFile( strFile, 2, True )
objFile.WriteLine( strUser )
objFile.WriteLine( strPass )
objFile.WriteLine( Mode )
objFile.WriteLine( strCMD )
objFile.WriteLine( "bye" )
objFile.Close()
Set objShell = WScript.CreateObject("WScript.Shell")
SET WSX = objShell.Run "cmd /c " & COMMAND_FTP & strFile & " " &
strHost,1,TRUE
strErrorLog = objTempFldr.Path & "ftpErrors.txt"
strLog = objTempFldr.Path & "ftpLog.txt"
Set objFile = objFSO.OpenTextFile( strErrorLog, 2, True )
objFile.Write( ReturnCode.ReadAll() )
objFile.Close()
Set objFile = objFSO.OpenTextFile( strLog, 2, True )
objFile.Write( Output.ReadAll() )
objFile.Close()
set objFSO = nothing
Set objRegExp = New RegExp
objRegExp.IgnoreCase = True
objRegExp.Pattern = "not connected|invalid command|error"
If (objRegExp.Test( Output.ReadAll ) = True ) or (objRegExp.Test(
ReturnCode.ReadAll ) ) Then
FTP = False
Else
FTP = True
End If
Set objRegExp = nothing
End Function
'//End
.
- Follow-Ups:
- Re: wScript.Shell Problems
- From: joseomjr@xxxxxxxxx
- Re: wScript.Shell Problems
- References:
- wScript.Shell Problems
- From: Nico VanHaaster
- wScript.Shell Problems
- Prev by Date: Re: Error handling bug on GetObject?
- Next by Date: Re: wScript.Shell Problems
- Previous by thread: wScript.Shell Problems
- Next by thread: Re: wScript.Shell Problems
- Index(es):
Relevant Pages
|