自動化されたパイプラインプロセスの一部としてSFTPサーバーにファイルをアップロードする必要があります。できないインタラクティブ)。 SSHアクセス権がないためできないscpまたはrsyncを使用してください。
私は使用していくつかの成功を収めました。この回答で提案されたソリューション:
sftp user@server <<EOF
put localPath remotePath
EOF
しかし、失敗しても何の兆候もないので、より安定したものを探しています。たとえば、SFTP サーバーからダウンロードするには、次の構文を使用できます。
sftp user@server:remotePath localPath
アップロードに対応するチラシはありますか?
ベストアンサー1
sftpの「バッチモード」を使用できます。マニュアルから:
> -b batchfile
> Batch mode reads a series of commands from an input batchfile instead of stdin. Since it lacks user interaction it
> should be used in conjunction with non-interactive authentication. A batchfile of ‘-’ may be used to indicate
> standard input. sftp will abort if any of the following commands fail: get, put, reget, reput, rename, ln, rm,
> mkdir, chdir, ls, lchdir, chmod, chown, chgrp, lpwd, df, symlink, and lmkdir. Termination on error can be sup‐
> pressed on a command by command basis by prefixing the command with a ‘-’ character (for example, -rm /tmp/blah*).
つまり、コマンドを使用して一時ファイルを作成し、「sftp -b tempfile user@server」を使用してファイルからコマンドを実行します。
このタイプのタスクを実行する他のツール(例:lftp)があります。