我是Unix和ksh脚本编写的新手。我写了一个脚本来解密gpg消息。我得到了这个错误,我不知道如何解决。我希望有人能看看我的剧本,帮我弄清楚发生了什么。谢谢你能提供的任何帮助。错误如下:
gpg: processing message failed: eof
这是我的脚本:
#!/bin/ksh
####################################################################
# 1. Decrypt Inbound File #
# #
# Two parms are required: output file #
# encrypted file(to be decrypted) #
# #
####################################################################
# Variable declaration #
####################################################################
outputF=$1
encryptedF=$2
id=$$
####################################################################
# print_message #
# prints messages to log file #
####################################################################
print_message()
{
message="$1"
echo "`date '+%m-%d-%y %T'` $message"
}
#####################################################################
# Validate input parameters and existence of encrypted file #
#####################################################################
if [ $1 -eq ""] || [ $2 -eq ""]
then
print_message "Parameters not satisfied"
exit 1
fi
if [ ! -f $encryptedF ]
then
print_message "$id ERROR: $encryptedF File does not exist"
exit 1
fi
#####################################################
# Decrypt encryptedF #
#####################################################
gpg --output "$outputF" --decrypt "$encryptedF"
echo "PASSPHRASE" | gpg --passphrase-fd 0
print_message "$id INFO: File Decrypted Successfully"
这不是gpg问题:-)您的脚本尝试运行两次gpg二进制文件。第一个调用尝试解码文件:
gpg --output "$outputF" --decrypt "$encryptedF"
由于没有提供密码短语输入方式,gpg尝试从控制台读取密码短语。现在会发生什么,取决于你的gpg配置、ksh行为等,但我怀疑与STDIN的交互在某种程度上被削弱了,导致了EOF错误。
问题的解决方案:您必须将密码短语源添加到解密调用中:
echo "PASSPHRASE" | gpg --passphrase-fd 0 --output "$outputF" --decrypt "$encryptedF"