|
|
||||
|
Chapter 11: Scripting
The WS_FTP Scripting Utility allows you to group any number of file transfer tasks into a script that can be executed with one action. This can be especially useful for file transfers that you do repeatedly.
This chapter gives an overview of the Scripting Utility and some examples of how you might use it. For detailed instructions on using the Scripting Utility, start the Scripting Utility and use its online Help.
- Connect to FTP sites
- Upload or download files
- Set the transfer mode
- Make, delete, and rename folders
- Delete and rename files
- Execute a DOS command
Scripts can also have some limited flow control. They can:
- Check for the success or failure of the previous command
- Jump to another point in the script if either success or
failure is detectedSuppose you post weekly reports on your company's FTP server for your co-workers in other cities to download. Let's assume you place the current week's reports in a folder named Current. You could create a script that:
- Changes the name of last week's Current folder to Prior.
- Creates a new folder named Current.
- Uploads your current weekly reports to the Current folder.
You can also create scripts for downloads that you do repeatedly.
Using Scripting
Start the Scripting Utility by doing one of the following:
- From the Tools menu, select Script.
- Click the Windows Start button and select Programs -> WS_FTP Pro -> WS_FTP Pro Scripting Utility.
Writing and Debugging Scripts
To write and/or debug a script, start the Scripting Utility.
The Script Editor/Debugger window appears
.
An MS-DOS window is automatically opened behind the Editor/Debugger window to show you the output of SHELL commands.
Executing Scripts
You can execute scripts from either the Command Prompt or
from the Scripting Utility itself.Executing a Script from the Command Prompt
Go to the Command Prompt and type ftpscrpt followed by the appropriate command line parameters. For example:
ftpscrpt -f script1.scpThere are other parameters you can use with the ftpscrpt command. For detailed information, go to the Scripting Utility online Help and see "Executing Scripts."
To be able to run a script from any location on your hard disk, we recommend that you place the Scripting Utility folder in the Path statement in your Autoexec.bat file - if you are running Windows 98, Windows ME, and Windows XP. If you're using Windows NT or Windows 2000, add the WS_FTP Pro folder to the path variable in the System Environment.
Running a Script from the Scripting Utility
To run a script from the Scripting Utility, start the utility, open
the script, and click Go.Example
In the following example, the script:
- Turns on the Trace command to send detailed information to
the transfertrace.txt file.- Creates a log called transferlog.txt in the C:\ directory.
- Logs onto the server with the user name sdavis.
- Logs onto the server with the password fourthandgoal.
- Connects to the FTP server ftp.mywebprovider.com.
- Changes the remote directory to /user/sdavis/images.
- Changes the local directory to C:\My Documents\My Pictures
- If the MGET is successful, the script executes the FILEDELETE label.
- If the MGET fails, the script executes the DISCONNECT label.
- All files ending in .jpg are copied from the remote directory to the local directory.
- This line identifies the FILEDELETE label.
- All files ending in .jpg are deleted from the /user/sdavis/images remote folder.
- This line identifies the DISCONNECT label.
- Disconnects from the FTP server.
|
Ipswitch, Inc. http://www.ipswitch.com |
| ©Ipswitch 2003 | |||