FTP Shell.Exec 
Author Message
 FTP Shell.Exec

When running FTP with input and output redirected to files, it is
necessary to include the password in the "in" file.  I would like to
use Shell.Exec (WSH 5.6) to run the FTP command line utility, because
this seems to cause FTP to prompt for the password.  BUT, the Exec
command with FTP seems to have some limitations ...
1)  All commands, including "quit", must be written to StdIn before
any output appears in StdOut.
2)  Because of 1), only a limited number of commands can be processed.
3)  Input commands are not echoed to StdOut (only replies).

Any insights would be most appreciated.

Here is the code

Option Explicit

Dim Shell : Set Shell = WScript.CreateObject("WScript.Shell")
Dim oExec : set oExec = Shell.Exec("ftp -n" )

oExec.StdIn.WriteLine "open localhost"  
oExec.StdIn.WriteLine "user anonymous"
' cmd (dos) window will prompt for password at this point
oExec.StdIn.WriteLine "dir "

' hangs if the following line is omitted
oExec.StdIn.WriteLine "quit"  

Do Until oExec.Status <> 0 _
   And   oExec.StdErr.AtEndOfStream _
   And   oExec.StdOut.AtEndOfStream

          If Not oExec.StdOut.AtEndOfStream Then
          Elseif Not oExec.StdErr.AtEndOfStream Then
          End If

   WScript.Sleep 1000


Set oExec = Nothing

Mon, 05 Jul 2004 10:05:42 GMT  
 [ 1 post ] 

 Relevant Pages 

1. difference between Shell.run and Shell.exec

2. No FTP output when launched with Exec method

3. FTP and Run vs Exec methods

4. WSH 5.6 Beta - Shell.Exec

5. Shell.Exec

6. Using Scripting.Shell Exec command to capture the results of a SFTP ls command

7. Launching an exec from a client script using shell

8. Wscript.Shell Exec method

9. wscript.shell.exec STDOUT / ReadAll size limit?

10. WSH 5.6 beta - Shell.Exec

11. wscript.shell in .asp to run ftp script

12. Great scripts: FTP.scriptlet and Shell.scriptlet


Powered by phpBB® Forum Software