Windows SFTPサーバーからダウンロードしたEMRのファイルを解凍できません。

Windows SFTPサーバーからダウンロードしたEMRのファイルを解凍できません。

以下のコードを使用してSFTPサーバーからファイルをダウンロードしていますが、ダウンロードしたファイルを解凍するのに問題があります。

コードは次のとおりです。

#!/bin/bash

sudo yum -y install expect

cd /mnt/Additional_Backup/SFTP_Scripts/

################################ Unzipping file MDTR ################################
if [ "$1" = "ARG1" ]; then

rm RemoteFileList.txt
echo ''>  RemoteFileList.txt

expect -c "
spawn sftp -o StrictHostKeyChecking=no [email protected]:/
expect \"Enter password:\"
send \"*********\n\"
expect \"sftp>\"
log_file -noappend RemoteFileList.txt
send \"ls -1t\n\"
expect \"sftp>\"
log_file
expect \"sftp>\"
send \"bye\n\"
interact
"

sed '1c\''' RemoteFileList.txt > text1.txt

head -n 2 text1.txt > arguments.txt


head -n 1 arguments.txt > arg1
tail -n 1 arguments.txt > arg2


read file1 < arg1
read file2 < arg2

rm -fv arg*
rm text1.txt
rm RemoteFileList.txt

cd /mnt/Additional_Backup/SFTP_Scripts/$1/

expect -c "
set timeout 1000
spawn sftp -o StrictHostKeyChecking=no [email protected]
expect \"Enter password:\"
send \"********\r\"
expect \"sftp>\"
send \"cd /mnt/Additional_Backup/SFTP_Scripts/$1/\r\"
expect \"sftp>\"
send \"get $file1\r\"
expect {
  "*100%*" { }
  timeout { exit 2 }
}
expect \"sftp>\"
send \"get $file2\r\"
expect {
  "*100%*" { }
  timeout { exit 2 }
}
expect \"sftp>\"
send \"bye\r\"
expect eof
"
    echo "Unzipping ARG1 files in progress"

        unzip -o "$file1"
        unzip -o "$file2"


        echo 'All unzip done."
fi

ただし、スクリプトをデバッグすると、o / pの下の値が得られます。

+ echo Unzipping MMIT files in progress
Unzipping MMIT files in progress
+ unzip -o $'MMITPARFeed2.0_06_01_2020.zip\r'
.ZIP.or MMITPARFeed2.0_06_01_2020.ziped2.0_06_01_2020.zip
+ unzip -o $'MMITDataFeed2.0_06_01_2020.zip\r'
.ZIP.or MMITDataFeed2.0_06_01_2020.ziped2.0_06_01_2020.zip
+ echo 'All unzip done. Deleting existing folders from HDFS.'
All unzip done.

unzip コマンドを手動で実行すると正常に動作します。

私はここで+ unzip -o $'MMITDataFeed2.0_06_01_2020.zip\r'ファイルを抽出する正確な値が得られていないと思います。

tar私もコマンドを試しましたjar

誰でも同じ問題を解決するのに役立ちますか?

よろしくお願いします...! ! !

ベストアンサー1

おすすめ記事