The usual way to start PSFTP is from a command prompt, much like PSCP. To do this, it will need either to be on your PATH or in your current directory. To add the directory containing PSFTP to your PATH environment variable, type into the console window:
set PATH=C:\path\to\putty\directory;%PATH%
Unlike PSCP, however, PSFTP has no complex command-line syntax; you just specify a host name and perhaps a user name:
psftp server.example.com
or perhaps
psftp fred@server.example.com
Alternatively, if you just type psftp on its own (or double-click the PSFTP icon in the Windows GUI), you will see the PSFTP prompt, and a message telling you PSFTP has not connected to any server:
C:\>psftp
psftp: no hostname specified; use "open host.name" to connect
psftp>
At this point you can type open server.example.com or open fred@server.example.com to start a session.
PSFTP accepts all the general command line options supported by the PuTTY tools, except the ones which make no sense in a file transfer utility. See
section 3.8.3
for a description of these options. (The ones not supported by PSFTP are clearly marked.)
PSFTP also supports some of its own options. The following sections describe PSFTP's specific command-line options.
•
6.1.1 -b: specify a file containing batch commands
•
6.1.2 -bc: display batch commands as they are run
•
6.1.3 -be: continue batch processing on errors
•
6.1.4 -batch: avoid interactive prompts
6.1.1 -b: specify a file containing batch commands
In normal operation, PSFTP is an interactive program which displays a command line and accepts commands from the keyboard.
If you need to do automated tasks with PSFTP, you would probably prefer to specify a set of commands in advance and have them executed automatically. The -b option allows you to do this. You use it with a file name containing batch commands. For example, you might create a file called myscript.scr containing lines like this:
cd /home/ftp/users/jeff
del jam-old.tar.gz
ren jam.tar.gz jam-old.tar.gz
put jam.tar.gz
chmod a+r jam.tar.gz
and then you could run the script by typing
psftp user@hostname -b myscript.scr
When you run a batch script in this way, PSFTP will abort the script if any command fails to complete successfully. To change this behaviour, you can add the -be option (
section 6.1.3
).
PSFTP will terminate after it finishes executing the batch script.
6.1.2 -bc: display batch commands as they are run
The -bc option alters what PSFTP displays while processing a batch script specified with -b. With the -bc option, PSFTP will display prompts and commands just as if the commands had been typed at the keyboard. So instead of seeing this:
C:\>psftp fred@hostname -b batchfile