我有这个脚本:

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:



因此使用:

-get $clientLocation/$filePattern2 $myLocation

10-08 01:28