用于将文件从 Infa_shared 目录移动到远程 SFTP 服务器的 Shell 脚本

用于将文件从 Infa_shared 目录移动到远程 SFTP 服务器的 Shell 脚本

我的要求是将文件 ( DailyRenewalsYYYYMMDD.txt) 从 infa unix 服务器移动data/infa_shared_SrcFiles/ABC/到远程服务器。我创建了一个 shell 脚本。

Informatica下面是我正在使用并通过命令任务调用它的脚本:

Parameters to Pass  
$1 - SOURCE  Path  
$2 - Remote Server Path  
$3 - PUT Logfile  
$4 - Email Subject & Body  
#######################################################################################

MFT_HOST='10.XX.X.XXX'  
MFT_USER='XXXXX'  
MFT_PSWD='*****'  
FAILURE_EMAIL='[email protected]'  
SUCCESS_EMAIL='[email protected]'  

cd $SCRIPT_PATH  
rm -f $LOG_PATH/$3  
 
sftp $MFT_USER@$MFT_HOST:$REMOTE_DIR_PATH <<< $'put $SOURCE_PATH' >> $LOG_PATH 2>&1  

#*I have used below command as well, even this didn't worked*#  
##sftp $MFT_USER:$MFT_PSWD@$MFT_HOST:$REMOTE_DIR_PATH <<< $'put $SOURCE_PATH' >> $LOG_PATH 2>&1  

export RC=$?  
if [[ "$RC" > 0 ]];  
then  
echo `date +"%m-%d-%y_%T"` >> $LOG_PATH/$3  
echo "ERROR: $4 Put File to REMOTE Server Failed" >> $LOG_PATH/$3  
mail -s "$4 Put File to REMOTE Server Failed" $FAILURE_EMAIL<<EOF  
"$4" File is NOT present in SOURCE PATH. Check log for details.  
EOF  
exit -1  
else  
echo `date +"%m-%d-%y_%T"` >> $LOG_PATH/$3  
echo "SUCCEEDED: $4 Put File to REMOTE Server Succeeded." >> $LOG_PATH/$3  
mail -s "$4 Put File to REMOTE Server Successfully Completed" $SUCCESS_EMAIL<<EOF  
"$4" File Successfully Transferred to REMOTE Server. Check log for details.  
EOF  
fi  
exit 0  

#############################

通过命令任务中的 shell 脚本执行此命令后,我收到错误

THIS IS A PRIVATE COMPUTER SYSTEM ---  
USAGE MAY BE MONITORED AND UNAUTHORIZED ACCESS  
OR USE MAY RESULT IN CRIMINAL OR CIVIL PROSECUTION  
Permission denied, please try again.  
Received disconnect from MFT_HOST port 22:2: Too many authentication failures for MFT_USER  
Authentication failed.  
Couldn't read packet: Connection reset by peer  

sftp但是,如果我在编辑器中执行上述相同的命令putty,那么它会提示我输入密码,并在给出密码后,它将文件复制到远程服务器。

在此输入图像描述

笔记:我没有expect安装实用程序,所以我无法使用它。

相关内容