|
|
||||
|
Chapter 14: Using the Command Line
You can use the command line from the MS-DOS prompt to run the
WS_FTP Pro Classic interface.When you use the command line, you are actually running a subset of the functionality of the Classic interface. Using the command line, you can:
- Upload and download files
- Specify ASCII or binary transfer mode
- Convert file names to lowercase when uploading
- Set up pre-scheduled transfers
- Create batch files that will handle multiple commands
Basic Command Line Syntax
The following illustrates the correct command line syntax, broken down by argument type.
(command name: wsftppro) (source) (destination)Written out, a command using this format would look like this:
wsftppro -s local:c:\tartan.bmp -d robert!border:/pub/tartan.bmpThe section below shows the breakdown of that command into the parts illustrated above. The command name wsftppro must always be placed in the beginning of the command.
Site Information
wsftppro -s local:c:\tartan.bmp -d robert!border:/pub/tartan.bmp
If you use a configured site from the command line, WS_FTP Pro uses the User ID, Password, and Account Name you saved in the site configuration. To do this, place the site folder and site profile in front of the remote directory (this can be either the source or the destination). The site folder and site profile has to be separated by the ! symbol. In the example above, we use the border site profile stored in the robert folder.
If you have saved a password with the site, WS_FTP logs you on using the saved password. If you have not saved a password with the site, you will receive the regular password prompt, unless you use the -u and -w arguments.
wsftppro -u username -w password -s robert!border:/pub/tartan.bmp -d local:c:\armstrong\If you have saved an account name in the site configuration, the command
line logs you on using the saved account name. If you have not saved an account name, you can use the -c argument to specify the account name
when you enter the command line. For example:wsftppro -c account -s robert!border:/pub/tartan.bmp -d local:c:\armstrong\If you do not use a configured site profile, you must put the IP address, URL, or host name in the source or destination argument to connect to that site. See the Transfer Source and Transfer Destination sections for examples of command line commands that use this.
Transfer Source
wsftppro -s local:c:\tartan.bmp -d robert!border:/pub/tartan.bmp
The transfer source argument begins with the -s argument, followed by the label for the source, and the path to the item or items being transferred. If the source of the transfer is your local system, the source label is local. If you are doing a download, the source label is either the site folder!site name or the IP address, FTP URL, or Host name of the FTP site. For example:
wsftppro -s robert!border:/pub/tartan.bmp -d local:c:\tartan.bmpwsftppro -s ftp://username:password@border.ipswitch.com/pub/tartan.bmp -d local:c:\armstrong\wsftppro -u username -p password -s 156.21.50.78:/pub/tartan.bmp -d local:c:\Transfer Destination
wsftppro -s local:c:\tartan.bmp -d robert!border:/pub/tartan.bmp
The transfer destination argument begins with the -d argument, followed by the label for the destination, and the path to where item or items are being transferred to. If the destination is your local system, the destination label is local. If you are doing an upload, the destination label is either the site folder!site name (as in the example above) or the IP address, FTP URL, or Host name of the FTP site. For example:
wsftppro -s local:c:\tartan.bmp -d ftp://username:password@border.ipswitch.com/ pub/tartan.bmpwsftppro -s local:c:\tartan.bmp -u username -w password -d 156.21.50.78:/pub/tartan.bmp
File Transfer Options
Uploading Files
To upload a file, use the basic command syntax with the file or files you want to upload identified in the source argument. For example; if you want to copy the file tartan.bmp from the armstrong folder on your C: drive and place it in the /pub/ folder on the site identified in the border site profile use:
wsftppro -s local:c:\armstrong\tartan.bmp -d robert!border:/pub/tartan.bmpwsftppro -s local:c:\armstrong\tartan.bmp -d robert!border:/pub/Notice that the second option omits the file name from the destination location. You can do this when you want the transferred file to have the same name as it does in the source location. However, note that you must enter the trailing slash after the destination folder in order for this to work.
Downloading Files
Use the same command syntax as described above for downloading files, except that, the source of the transfer is the remote system instead of your local system.
wsftppro -s robert!border:/pub/tartan.bmp -d local:c:\armstrong\tartan.bmpIn the example above, we are connecting to the remote system using the border site profile and downloading the tartan.bmp file to the armstrong folder on our C: drive.
Renaming Files
To rename a file during the upload, enter a new file name after the destination folder. For example, to upload the Tag.doc file and rename it NewTag.doc on the FTP site, type:
wsftppro -s local:c:\sports\Tag.doc -d robert!border:/pub/drop/NewTag.docTransferring multiple files from the same location
If all the files you want to transfer are in the same folder, you can use the wildcard characters, * and ?, in the file name. For example, if you want to upload all of the files in C:\Sports\ use:
wsftppro -s local:c:\sports\*.* -d robert!border:/pub/drop/Or, to transfer all .doc files in the same folder, enter (at the MS-DOS prompt or in a batch file):
wsftppro -s local:c:\sports\*.doc -d robert!border:/pub/drop/To transfer multiple files not in the same folder, see "Multiple Folders or Commands".
Converting File Names to Lower Case
When uploading files, you can have WS_FTP Pro convert file names to lower case by adding the -lower argument at the end of the command line. For example, if the file you want to transfer is named Tag.doc, WS_FTP Pro can upload it as tag.doc by using:
wsftppro -s local:c:\sports\Tag.doc -d robert!border:/pub/drop/ -lower
File Transfer Modes
You can transfer files in binary mode or in ASCII mode. We recommend using binary mode to transfer all files unless you know the file contains only text, then you are able to use ASCII mode.
To specify the transfer mode, you use the -binary or -ascii argument at the end of the command string.
When you do not specify the transfer mode in the command line, WS_FTP Pro transfers the file in whatever file transfer mode is the default in the WS_FTP Pro Classic interface. Therefore, if you plan on using the command line more than just occasionally, set the Startup Transfer Mode to Auto Detect.
Transferring Files and Folders with Spaces in the Name
If you are transferring a file whose name has spaces in it, you have two options. You can enclose that portion of the command line in quotes, or use the MS-DOS name of the file (as shown in the Dir listing you get from the MS-DOS prompt.)
Enclosing the Command Line in Quotes
If the file you want to transfer is named my tartan.bmp, use:
wsftppro -s "local:c:\armstrong\my tartan.bmp" -d "robert!border:/pub/my tartan.bmp"Using the MS-DOS Name
If the file you want to transfer is named my tartan.bmp in Windows 95, but appears as my~1.doc when you use the Dir command at the MS-DOS prompt, you can use the MS-DOS file name to transfer the file. To do this (using the first example in this chapter), enter (at the MS-DOS prompt or in a batch file):
wsftppro -s local:c:\armstrong\my~1.bmp -d robert!border:/pub/my~1.bmpUsing a Batch File
You run the command by invoking the .bat file at the MS-DOS prompt, double-clicking the icon for the .bat file from within Windows, or running the .bat file from another application (such as WS_FTP Pro Scheduler).
Here is a batch file (for the example at the beginning of this chapter) as viewed from a Windows text editor:
![]()
When you run the batch file named tartan.bat, WS_FTP Pro uploads the tartan.bmp file to the border FTP site.
Note that using a batch file involves placing the command name wsftppro at the beginning of each line in the file. Since each instance of the command name starts the WS_FTP Pro application (and connects to the FTP site), you would only use a batch file to work with one command at a time. If, on the other hand, you want to issue a group of commands, follow the procedure in "Multiple Folders or Commands".
Remember that if a file name has a space in it, you must enclose that entire argument in quotes.
Multiple Folders or Commands
To transfer files to or from multiple source or destination folders, or to issue multiple commands, use the -m argument followed by the name of a text file that contains the commands. To transfer files from several locations on the hard disk described in the first example in this chapter, enter (at the MS-DOS prompt or in a batch file) something like:
wsftppro -m xferall.txtwhere the content of xferall.txt (as viewed in Windows Notepad) is:
![]()
- The command name wsftppro must not appear in the text file
- Each line of text must contain only one command line.
- Each command line can contain any of the arguments described in
this chapter.- If a file or folder name has a space in it, you must enclose that entire argument in quotes.
Pre-scheduled Transfers ("Automated Transfers")
You can use the command line to schedule transfers that you want to run automatically. To do this, you create a batch file as described above, and then run the batch file using WS_FTP Scheduler. For more information, see "Chapter 12: Scheduler".
When you use the command line to perform a pre-scheduled transfer, you may use the -quiet parameter to prevent WS_FTP Pro from displaying a message box if an error occurs. This is particularly useful for avoiding a situation in which WS_FTP Pro might otherwise prompt for user input, such as clicking the OK button in an error message. This way, you can pre-schedule transfers to run automatically when you're not at your computer. (When you return to the computer, you can always check the log file to see if there were any problems.)
To use the examples shown previously, you could do a pre-scheduled transfer by creating the following batch file:
![]()
as well as the following text file:
![]()
Then, you could have the Scheduler run the auto10.bat file at 10:00 PM each night.
Remember that if a file name has a space in it, you must enclose that entire argument in quotes.
Extras
Here are a few more arguments and uses of the command line that some users have found helpful. These are listed below.
To have WS_FTP Pro display a dialog box that prompts you for the command line, type: wsftppro -ask
To launch the WS_FTP Pro Classic interface and default to the site configuration for the border site: wsftppro -p robert!border
To prevent WS_FTP Pro from displaying error messages, use the -quiet argument. This is useful if you want to do automated transfers when no one is around to respond to a message. An example:
wsftppro -s local:c:\armstrong\tartan.bmp -d robert!border:/pub/tartan.bmp - quietSummary
Here is a list of all arguments you can use in the command line.
|
Ipswitch, Inc. http://www.ipswitch.com |
| ©Ipswitch 2003 | |||