FTP does not execute

Author Message
snufse

  • Total Posts : 36
  • Scores: 0
  • Reward points : 0
  • Joined: 9/6/2007
  • Status: offline
FTP does not execute Friday, August 20, 2010 8:57 AM (permalink)
0
When application executes I cannot see any script being run in the command prompt windows.
 
Public Sub Build_FTP_Command_String()
objFSO = Server.CreateObject(
"Scripting.FileSystemObject")
objTextFile = objFSO.CreateTextFile(
"c:\temp\ftpfile6.txt", True)
objTextFile.WriteLine(
"open " & strHost)
objTextFile.WriteLine(strLoginId)
objTextFile.WriteLine(strPassWord)
objTextFile.WriteLine(strMode)
objTextFile.WriteLine(
"prompt on")
objTextFile.WriteLine(
"put " & strLocalFolder & strFilePut & " " & strRemoteFolder)
objTextFile.WriteLine(
"quit")
End Sub
Public Sub Execute_FTP_Process()
objShell = CreateObject(
"WScript.Shell")
objShell.Exec(cmdFTP & Chr(34) &
"c:\temp\ftpfile6.txt" & Chr(34))
objFSO =
Nothing
objTextFile = Nothing
objFSO = Nothing
End Sub
 
#1
    ehvbs

    • Total Posts : 3320
    • Scores: 112
    • Reward points : 0
    • Joined: 6/22/2005
    • Location: Germany
    • Status: offline
    Re:FTP does not execute Saturday, August 21, 2010 6:43 AM (permalink)
    0
    There is no top level code calling the subs. You should read the Docs
    to learn about subs/functions and study

        http://www.visualbasicscript.com/fb.ashx?m=82006

    and

        http://www.visualbasicscript.com/fb.ashx?m=81456


     
    #2
      snufse

      • Total Posts : 36
      • Scores: 0
      • Reward points : 0
      • Joined: 9/6/2007
      • Status: offline
      Re:FTP does not execute Monday, August 23, 2010 1:54 AM (permalink)
      0
      The Page_Load is calling the subs, I did not include it on purpose.
       
      Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
      Build_FTP_Command_String()
      Execute_FTP_Process()
      End Sub
       
      Now when I neter the "Execute" sub I see a DOS screen but no scripts being run. Does my code seem correct? All my variables have values at this point. Thank you.
       
      #3
        snufse

        • Total Posts : 36
        • Scores: 0
        • Reward points : 0
        • Joined: 9/6/2007
        • Status: offline
        Re:FTP does not execute Monday, August 23, 2010 2:35 AM (permalink)
        0
        Now, seems like script is running fine and does the ftp to the remote machine. What I do not understand is why I do not see any commands being executed in the dos window since I have prompt = on?
         
        Also, how can I delete the text file created after ftp has completed? I am executing the DeleteFile command but getting error:
         
        objShell.Exec(cmdFTP & Chr(34) & "c:\temp\ftpfile6.txt" & Chr(34))
        objFSO.DeleteFile("c:\temp\ftpfile6.txt")
         
        Error on objFso.DeleteFile ... System.Security.SecurityException: Exception from HRESULT: 0x800A0046 (CTL_E_PERMISSIONDENIED)
         
        I thought if I could create a file I should also be allowed to delete same file or ????
          
          
         
        Thank you.
        <message edited by snufse on Monday, August 23, 2010 3:48 AM>
         
        #4
          ehvbs

          • Total Posts : 3320
          • Scores: 112
          • Reward points : 0
          • Joined: 6/22/2005
          • Location: Germany
          • Status: offline
          Re:FTP does not execute Monday, August 23, 2010 3:46 AM (permalink)
          0
          If you zap objFSO, you can't use it later on. (Just shows that you shouldn't
          Set objects to Nothing for nothing)

          P.S. Get rid of the 'pass me by value ()' too.
          <message edited by ehvbs on Monday, August 23, 2010 3:48 AM>
           
          #5
            snufse

            • Total Posts : 36
            • Scores: 0
            • Reward points : 0
            • Joined: 9/6/2007
            • Status: offline
            Re:FTP does not execute Monday, August 23, 2010 4:11 AM (permalink)
            0
            Thank you for the tip...
             
            Tried to work it this way:
             
            Public Sub Execute_FTP_Process()
            Try
            objShell = CreateObject("WScript.Shell")
            objShell.Exec(cmdFTP & Chr(34) & strFTPScriptFileName & Chr(34))
            Dim file
            If objFSO.fileExists(strFTPScriptFileName) Then
            file = objFSO.GetFile(strFTPScriptFileName)
            file.Delete()
            End If
            objFSO = Nothing
            Catch ex As Exception
            Dim ErrorString As String
            ErrorString = ex.ToString
            Dim mystr As String = Finally
            End Try
            End Sub
             
             
            Still getting error on the file delete:
            System.Security.SecurityException: Exception from HRESULT: 0x800A0046 (CTL_E_PERMISSIONDENIED)
             
             
            #6
              ehvbs

              • Total Posts : 3320
              • Scores: 112
              • Reward points : 0
              • Joined: 6/22/2005
              • Location: Germany
              • Status: offline
              Re:FTP does not execute Monday, August 23, 2010 4:32 AM (permalink)
              0
              Being a bit slow on the uptake, I realized but now, that we aren't talking
              VBScript. So disregard everything I wrote.

              (could one of the admins move this topic to the "Other Languages" forum,
              please)
               
              #7

                Online Bookmarks Sharing: Share/Bookmark

                Jump to:

                Current active users

                There are 0 members and 1 guests.

                Icon Legend and Permission

                • New Messages
                • No New Messages
                • Hot Topic w/ New Messages
                • Hot Topic w/o New Messages
                • Locked w/ New Messages
                • Locked w/o New Messages
                • Read Message
                • Post New Thread
                • Reply to message
                • Post New Poll
                • Submit Vote
                • Post reward post
                • Delete my own posts
                • Delete my own threads
                • Rate post

                2000-2012 ASPPlayground.NET Forum Version 3.9