Windows Scripting
  Home arrow Windows Scripting arrow Using FTP in WSH
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
WINDOWS SCRIPTING

Using FTP in WSH
By: Nilpo
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 3
    2007-08-13

    Table of Contents:
  • Using FTP in WSH
  • Creating the Unattended FTP script
  • Putting the WSH script together
  • Security considerations when using unattended ftp scripts

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Using FTP in WSH


    (Page 1 of 4 )

    From time to time you may find yourself creating scripts that require FTP support. Maybe you’re creating a script that will auto-update your web site contents or perhaps your script needs to check an ftp site for program updates or additional components to install.

    In any of these cases, it can be helpful to add FTP functionality to your scripts. Unfortunately, the Windows Script Host does not provide any method for doing so natively. You can, however, create a usable workaround using the command-line FTP utility included with Windows.

    Before we begin, let’s examine the command-line FTP utility. It’s called FTP.exe and is located in the System32 directory. Let’s take a peek at its command-line syntax.

    FTP [-v] [-d] [-i] [-n] [-g] [-s:filename] [-a] [-w:windowsize] [host]

    where:

    -v Suppresses display of remote server responses.

    -n Suppresses auto-login upon initial connection.

    -i Turns off interactive prompting during multiple file transfers.

    -d Enables debugging.

    -g Disables filename globbing (see GLOB command).

    -s:filename Specifies a text file containing FTP commands; the commands will automatically run after FTP starts.

    -a Use any local interface when binding data connection.

    -A Login as anonymous.

    -w:buffersize Overrides the default transfer buffer size of 4096.

    host Specifies the host name or IP address of the remote host to connect to.

    While you can use any of these switches to suit your needs, we’ll be concentrating on the –s switch. It allows us to specify an input file that contains a set of commands to be executed during the ftp session. This allows us to create an unattended ftp session.

    In other words, we can execute the ftp command without having to input anything interactively on the command line. This is perfect for our scripting needs. All we need to do is determine the necessary commands and create the text file before we execute the FTP command.

    More Windows Scripting Articles
    More By Nilpo


       · Hey, guys. I'm making my return to Windows Scripting with this workaround for a...
     

    WINDOWS SCRIPTING ARTICLES

    - More Windows Scripting Workarounds from Nilpo
    - Overloading Methods and More in VBScript
    - Improving MFC for Windows Vista
    - Regular Expressions in VBScript
    - Working with Dates in WMI
    - Completing Calendars with VBScript Date Func...
    - Building Calendars with VBScript Date Functi...
    - Working With Dates and Times in VBScript
    - Designing WCF DataContract Classes Using the...
    - Understanding Dates and Times in VBScript
    - Working With Arrays in VBScript
    - Compressed Folders in WSH
    - Using .NET Interops in VBScript
    - Nilpo`s Scripting Secrets, Vol I
    - Database operations using Silverlight 2.0 WC...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek