找不到文件时sftp避免退出
sftp avoid exit when file is not found
我有这个脚本:
filePattern='sor.log*'
filePattern2='sor.SOR.log*'
myLocation=/opt/tradertools/omer
clientLocation=/opt/tradertools/omer/sor/from
clientName=vmonitorlmpa
clientUser=root
clientPass=triltest
export SSHPASS=$clientPass
sshpass -e sftp -oStrictHostKeyChecking=no -oBatchMode=no -b - $clientUser@$clientName << !
get $clientLocation/$filePattern2 $myLocation
get $clientLocation/$filePattern $myLocation
bye
!
但是如果没有找到filepattern2
,它将退出。如何避免使用两个 SFTP 连接?
引用 sftp
man page:
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
我有这个脚本:
filePattern='sor.log*'
filePattern2='sor.SOR.log*'
myLocation=/opt/tradertools/omer
clientLocation=/opt/tradertools/omer/sor/from
clientName=vmonitorlmpa
clientUser=root
clientPass=triltest
export SSHPASS=$clientPass
sshpass -e sftp -oStrictHostKeyChecking=no -oBatchMode=no -b - $clientUser@$clientName << !
get $clientLocation/$filePattern2 $myLocation
get $clientLocation/$filePattern $myLocation
bye
!
但是如果没有找到filepattern2
,它将退出。如何避免使用两个 SFTP 连接?
引用 sftp
man page:
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
, andlmkdir
.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