![Windows SFTP 서버에서 다운로드한 EMR의 파일 압축을 풀 수 없습니다.](https://linux55.com/image/174357/Windows%20SFTP%20%EC%84%9C%EB%B2%84%EC%97%90%EC%84%9C%20%EB%8B%A4%EC%9A%B4%EB%A1%9C%EB%93%9C%ED%95%9C%20EMR%EC%9D%98%20%ED%8C%8C%EC%9D%BC%20%EC%95%95%EC%B6%95%EC%9D%84%20%ED%92%80%20%EC%88%98%20%EC%97%86%EC%8A%B5%EB%8B%88%EB%8B%A4..png)
아래 코드를 사용하여 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
.
누구든지 같은 문제를 해결하도록 도와줄 수 있나요?
미리 감사드립니다...! ! !