Windows Scripting
  Home arrow Windows Scripting arrow Page 2 - 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  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
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 / 2
    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 - Creating the Unattended FTP script


    (Page 2 of 4 )

    In order to understand better what needs to be in the unattended ftp script, let’s take a look at an example ftp session. Here I’ve simply connected to my ftp site and downloaded a file. For security purposes, all sensitive information has been changed in the output below.

    C:>ftp ftp.myserver.com

    Connected to ftp.myserver.com.

    220---------- Welcome to Pure-FTPd [TLS] ----------

    220-You are user number 4 of 50 allowed.

    220-Local time is now 13:14. Server port: 21.

    220-IPv6 connections are also welcome on this server.

    220-You will be disconnected after 15 minutes of inactivity.

    User (ftp.myserver.com:(none)): USERNAME

    331 User USERNAME OK. Password required

    Password:

    230-Your bandwidth usage is restricted

    230-User USERNAME has group access to: USERNAME

    230 OK. Current restricted directory is /

    ftp> cd /public_html/pub/examples

    250 OK. Current directory is /public_html/pub/examples

    ftp> get word.vbs

    200 PORT command successful

    150 Connecting to port 61110

    226-File successfully transferred

    226 0.006 seconds (measured here), 146.10 Kbytes per second

    ftp: 858 bytes received in 0.00Seconds 858000.00Kbytes/sec.

    ftp> close

    221-Goodbye. You uploaded 0 and downloaded 1 kbytes.

    221 Logout.

    ftp> bye

    I’ve used a bold font to indicate the information that I typed manually at the interactive prompt. Essentially, these entries become the commands that we’ll use in the unattended ftp script. You could add any other ftp commands that you like to your session. Each line will be executed in turn whenever a prompt appears that required user input.

    Here is what the unattended script for my ftp session would look like.

    USER username

    password

    cd /public_html/pub/examples

    get word.vbs

    Notice that you can safely leave out the close and bye commands. The ftp session will be terminated as soon as it reaches the end of the script file.

    There are a couple of things to keep in mind. First, know your ftp server. Some servers have different settings and may require other input. Second, avoid unexpected errors. Using commands like “binary” to specify a binary transfer mode for images or executables can prevent unwanted errors even though most servers will auto-sense the correct settings.

    It’s also important to suppress unwanted confirmations. If you are sending or receiving multiple files at once (using mput or mget, respectively) you will be prompted to continue before each transfer. You can suppress this by using the “prompt n” command prior to using mput or mget or you can use the –i switch in your ftp command line.

    In any case, test and retest your script to make sure it functions properly. If your script is going to be used for distribution, take care in making it fully compatible with all ftp servers on which it may be used.

    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

    - Introducing Two-Way Data Binding using Silve...
    - Silverlight 2.0 Application Development with...
    - Burning Multisession CDs with IMAPI2 in WSH
    - Creating a Silverlight 2.0 Application that ...
    - Burning CDs with the IMAPI2 Control
    - Burning CDs in Windows XP with WSH
    - Advanced Word Object Scripting
    - Reading and Printing Word Documents in WSH
    - Scripting Microsoft Word
    - Using WSH to Catalog MP3 Files
    - Reading MP3 ID3 Tags in WSH
    - A Brief Look at Menus in WPF
    - More Examples of Simplified Image Processing...
    - Completing a WPF To-Do List Application
    - Simplified Image Processing in GDI+





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
    Stay green...Green IT