By default, files copied with PSCP are timestamped with the date and time they were copied. The -p option preserves the original timestamp on copied files.
5.2.2.3 -q quiet, don't show statistics
By default, PSCP displays a meter displaying the progress of the current transfer:
mibs.tar | 168 kB | 84.0 kB/s | ETA: 00:00:13 | 13%
The fields in this display are (from left to right), filename, size (in kilobytes) of file transferred so far, estimate of how fast the file is being transferred (in kilobytes per second), estimated time that the transfer will be complete, and percentage of the file so far transferred. The -q option to PSCP suppresses the printing of these statistics.
5.2.2.4 -r copies directories recursively
By default, PSCP will only copy files. Any directories you specify to copy will be skipped, as will their contents. The -r option tells PSCP to descend into any directories you specify, and to copy them and their contents. This allows you to use PSCP to transfer whole directory structures between machines.
5.2.2.5 -batch avoid interactive prompts
If you use the -batch option, PSCP will never give an interactive prompt while establishing the connection. If the server's host key is invalid, for example (see
section 2.2
), then the connection will simply be abandoned instead of asking you what to do next.
This may help PSCP's behaviour when it is used in automated scripts: using -batch, if something goes wrong at connection time, the batch job will fail rather than hang.
5.2.2.6 -sftp, -scp force use of particular protocol
As mentioned in
section 5.2.1
, there are two different file transfer protocols in use with SSH. Despite its name, PSCP (like many
other ostensible scp clients) can use either of these protocols.
The older SCP protocol does not have a written specification and leaves a lot of detail to the server platform. Wildcards are expanded on the server. The simple design means that any wildcard specification supported by the server platform (such as brace expansion) can be used, but also leads to interoperability issues such as with filename quoting (for instance, where filenames contain spaces), and also the security issue described in
section 5.2.1
.
The newer SFTP protocol, which is usually associated with SSH-2 servers, is specified in a more platform independent way, and leaves issues such as wildcard syntax up to the client. (PuTTY's SFTP wildcard syntax is described in
section 6.2.2
.) This makes it
more consistent across platforms, more suitable for scripting and automation, and avoids security issues with wildcard matching.
Normally PSCP will attempt to use the SFTP protocol, and only fall back to the SCP protocol if SFTP is not available on the server.
The -scp option forces PSCP to use the SCP protocol or quit.
The -sftp option forces PSCP to use the SFTP protocol or quit. When this option is specified, PSCP looks harder for an SFTP server, which may allow use of SFTP with SSH-1 depending on server setup.
5.2.3 Return value
PSCP returns an ERRORLEVEL of zero (success) only if the files were correctly transferred. You can test for this in a batch file, using code such as this:
pscp file*.* user@hostname:
if errorlevel 1 echo There was an error
5.2.4 Using public key authentication with PSCP
Like PuTTY, PSCP can authenticate using a public key instead of a password. There are three ways you can do this.