Hello Mate,

I have a vb scripot function which will move files from my server to FTP.I have a problem in that ,which is the commands are not working and the files are not getting moved to the ftp .

This is my code

function sendToFtp(ftp_address,ftp_username,ftp_password,ftp_remote_directory,ftp_physical_path,ftp_files_to_put)
Dim objFSO, objTextFile, oScript, oScriptNet, oFileSys, oFile, strCMD, strTempFile, strCommandResult

'Dim ftp_address, ftp_username, ftp_password, ftp_physical_path, ftp_files_to_put
' Edit these variables to match your specifications
'ftp_address = "ftp.server.com"
'ftp_username = "username"
'ftp_password = "password"
'ftp_remote_directory = "subdirectory" ' Leave blank if uploading to root directory
'ftp_files_to_put = "file.txt"

'On Error Resume Next
Set oScript = Server.CreateObject("WSCRIPT.SHELL")
Set oFileSys = Server.CreateObject("Scripting.FileSystemObject")
Set objFSO = CreateObject("Scripting.FileSystemObject")
' Build our ftp-commands file
FTPFILENAME = "test"&Year(Now())&Month(Now())&Day(Now())&Hour(Now())&Minute(Now())&Second(Now())&".ftp"
Set objTextFile = objFSO.CreateTextFile(Server.MapPath("../MassUpload/" & FTPFILENAME))
objTextFile.WriteLine "lcd " & chr(34)&Server.MapPath("../MassUpload/")&chr(34)
objTextFile.WriteLine "open " & ftp_address
objTextFile.WriteLine ftp_username
objTextFile.WriteLine ftp_password

' Check to see if we need to issue a 'cd' command

If ftp_remote_directory <> "" Then
objTextFile.WriteLine "cd " & ftp_remote_directory
End If

objTextFile.WriteLine "prompt"
objTextFile.WriteLine "binary"
' If the file(s) is/are binary (i.e. .jpg, .mdb, etc..), uncomment the following line' objTextFile.WriteLine "binary"
' If there are multiple files to put, we need to use the command 'mput', instead of 'put'
If Instr(1, ftp_files_to_put, "*",1) Then
objTextFile.WriteLine "mput " & chr(34)&Server.MapPath("../MassUpload/" & ftp_files_to_put)&chr(34)
Else
objTextFile.WriteLine "put " & chr(34)&Server.MapPath("../MassUpload/" & ftp_files_to_put)&chr(34)
End If
objTextFile.WriteLine "bye"
objTextFile.Close

Set objTextFile = Nothing
' Use cmd.exe to run ftp.exe, parsing our newly created command file
strCMD = "ftp.exe -s:" & chr(34)& Server.MapPath("../MassUpload/" & FTPFILENAME)& chr(34)
'Response.Write strCMD

'Response.Flush

'strTempFile = "C:\" & oFileSys.GetTempName( )
strTempFile = Server.MapPath("../MassUpload/") & oFileSys.GetTempName( )
Response.Write strTempFile
'Response.Flush
' Pipe output from cmd.exe to a temporary file (Not :| Steve)
Call oScript.Run ("cmd.exe /c " & strCMD & " > " & strTempFile, 0, True)
Set oFile = oFileSys.OpenTextFile (strTempFile, 1, False, 0)

'On Error Resume Next
'Grab output from temporary file
strCommandResult = Server.HTMLEncode( oFile.ReadAll )
oFile.Close
' Delete the temporary & ftp-command files
''Call oFileSys.DeleteFile( strTempFile, True )
''Call objFSO.DeleteFile( chr(34) & Server.MapPath("../MassUpload/" & FTPFILENAME)& chr(34), True )
Set oFileSys = Nothing
Set objFSO = Nothing
' Print result of FTP session to screen
sendToFtp = strCommandResult
End Function

I have write permission to the MassUpload Folder .The file "test"&Year(Now())&Month(Now())&Day(Now())&Hour(Now())&Minute(Now())&Second(Now())&".ftp" is getting created and it has values correctly.

but the temporary file (which wil have the result of the commands which are executing). is not getting created and even if create the temp file using CreateTextFile the got created but there is nothing in it.

and when i write the commands (which will get executed ) i get the following.

strTempFile="D:\MassUploadrad3D5F3.tmp"

cmd.exe /c ftp.exe -s:"D:\MassUpload\testHBH2012431523.ftp" > "D:\MassUploadrad3D5F3.tmp"



Please advise me on this issue.

Thanks in advance,
Myself