且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

sftp避免在找不到文件时退出

更新时间:2023-11-22 15:30:52

引用 sftp手册页:

Quoting the sftp man page:

如果以下任何命令失败,

sftp将中止:getputregetreputrenamelnrmmkdirlslchdirchmodchownchgrplpwddfsymlinklmkdir.可以在命令的基础上通过在命令前面加上-字符(例如,-rm /tmp/blah*)来抑制错误终止.

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 suppressed on a command by command basis by prefixing the command with a - character (for example, -rm /tmp/blah*).

因此使用:

-get $clientLocation/$filePattern2 $myLocation