(PuTTYユーザマニュアルの日本語訳) 6.1 PSFTPを始める - 6.1 Starting PSFTP

http://the.earth.li/~sgtatham/putty/0.60/htmldoc/Chapter6.html#psftp-startingの日本語訳<< 6章: PSFTPを使ってファイルを安全に転送する - 目次に戻る - 6.2 PSFTPを実行する >>

訳文

PSFTPは通常コマンドプロンプトから起動します。PSCPと同様です。このように起動するには、PSFTPがPATHに含まれるかカレントディレクトリに存在する必要があります。PSFTPをPATH環境変数に追加するには、コンソールウィンドウで以下を入力します。

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%

PSCPと異なり、PSFTPには複雑なコマンドラインの文法がありません。ホスト名と必要であればユーザ名を指定するだけです。

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

別の方法として、psftpとだけ入力した場合(あるいはWindowsGUIPSFTPアイコンをダブルクリックした場合)、PSFTPプロンプトが表示され、PSFTPがサーバに接続を確立していないことを示すメッセージが表示されます。

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>

このとき、open server.example.comやopen fred@server.example.comと入力するとセッションを開始できます。

At this point you can type open server.example.com or open fred@server.example.com to start a session.

PSFTPでは、PuTTYツールがサポートする一般的なコマンドラインオプションを受け付けます。しかし、ファイル転送ユーティリティで意味を持たないオプションは例外的に受け付けられません。これらのオプションの詳細は3.8.3節を参照してください。(PSFTPでサポートされないオプションはわかるようになっています。)

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は独自のオプションもサポートします。以下のセクションではPSFTP固有のコマンドラインオプションを説明しています。

PSFTP also supports some of its own options. The following sections describe PSFTP's specific command-line options.

6.1.1 -b: バッチコマンドのファイルを指定する - 6.1.1 -b: specify a file containing batch commands

通常の操作では、PSFTPは対話的なプログラムであり、キーボード入力されたコマンドを表示します。

In normal operation, PSFTP is an interactive program which displays a command line and accepts commands from the keyboard.

PSFTPを使う作業を自動化したい場合、あらかじめ一連のコマンドを指定して、自動的に実行するとよいでしょう。これは行うには、-bオプションを使います。このオプションを使ってバッチコマンドのファイルを指定します。例えば、以下の行を含むmyscript.scrというファイルを作ります。

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

この方法でバッチスクリプトを実行した場合、コマンドが正常に終了しないとPSFTPスクリプトを中断します。-beオプション(6.1.3節を参照)を追加すれば、この動作を変更できます。

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も終了します。

PSFTP will terminate after it finishes executing the batch script.

6.1.2 -bc: 実行しているバッチコマンドを表示する - 6.1.2 -bc: display batch commands as they are run
  • bcオプションを指定すると、-bで指定したバッチスクリプトの処理中の表示内容が変わります。-bcオプションを指定すると、コマンドをキーボードから入力したかのように、PSFTPはプロンプトとコマンドを表示します。このオプションを指定しない場合、以下のようになります。

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
Sent username "fred"
Remote working directory is /home/fred
Listing directory /home/fred/lib
drwxrwsr-x    4 fred     fred         1024 Sep  6 10:42 .
drwxr-sr-x   25 fred     fred         2048 Dec 14 09:36 ..
drwxrwsr-x    3 fred     fred         1024 Apr 17  2000 jed
lrwxrwxrwx    1 fred     fred           24 Apr 17  2000 timber
drwxrwsr-x    2 fred     fred         1024 Mar 13  2000 trn

指定すると、以下のようになります。

you might see this:

C:\>psftp fred@hostname -bc -b batchfile
Sent username "fred"
Remote working directory is /home/fred
psftp> dir lib
Listing directory /home/fred/lib
drwxrwsr-x    4 fred     fred         1024 Sep  6 10:42 .
drwxr-sr-x   25 fred     fred         2048 Dec 14 09:36 ..
drwxrwsr-x    3 fred     fred         1024 Apr 17  2000 jed
lrwxrwxrwx    1 fred     fred           24 Apr 17  2000 timber
drwxrwsr-x    2 fred     fred         1024 Mar 13  2000 trn
psftp> quit
6.1.3 -be: エラーが発生してもバッチ処理を続ける - 6.1.3 -be: continue batch processing on errors

このオプションを指定すると、バッチファイルの実行中にコマンドの実行が失敗しても処理が続行されます。

When running a batch file, this additional option causes PSFTP to continue processing even if a command fails to complete successfully.

例えば、ファイルの存在を意識せずファイルを削除したい場合に役立ちます。

You might want this to happen if you wanted to delete a file and didn't care if it was already not present, for example.

6.1.4 -batch: 対話型のプロンプトを表示しない - 6.1.4 -batch: avoid interactive prompts
  • batchオプションを使うった場合、PSFTPの接続の確立時に対話型プロンプトが表示されなくなります。例えば、ホストキーが不正な場合(2.2節参照)、確認なしに接続は単純に中止されます。

If you use the -batch option, PSFTP 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.

スクリプトで自動的にPSFTPを実行する場合、この動作が役立つことがあります。-batchを指定した場合、バッチジョブは接続の失敗時にハングアップすることなく失敗します。

This may help PSFTP'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.

<< 6章: PSFTPを使ってファイルを安全に転送する - 目次に戻る - 6.2 PSFTPを実行する >>