问题描述
我在bash脚本编程一个可怕的初学者,我希望有人能帮助我走出这个问题。
有与preY项目独立脚本的一个问题。有说是应该发送电子邮件的线路,显然它的格式不正确。
反应=`mailsender -f$ mail_from-t$ MAIL_TO-u$ complete_subject\\
-s $ smtp_server -a $ file_list中-o信息文件=$ trace_file.msg\\
TLS =汽车的用户名= $ smtp_username \\
密码= \\'解密\\$ smtp_password参数\\\\``
在哪里mailsender是一个别名布兰登Zehm的PERL sendEmail脚本,$ smtp_password参数是密码的一个毫无意义的base64编码和解密是:
解密(){
回声$ 1| OpenSSL的ENC -base64 -d
}
因此,谁能告诉我,什么是错的脚本?作为参考,如果我只是用明文密码更换整个解密的一部分,它工作正常。即:
反应=`mailsender -f$ mail_from-t$ MAIL_TO-u$ complete_subject\\
-s $ smtp_server -a $ file_list中-o信息文件=$ trace_file.msg\\
TLS =汽车的用户名= $ smtp_username密码= actual_password`
做最简单的事情是避免反引号,并使用 $()
而不是 - 它们的巢干净,没有特殊需要转义:
响应= $(文件/项目/壳牌\\脚本/ printargs -f$ mail_from\\
-t$ MAIL_TO-u$ complete_subject-s $ smtp_server -a $ file_list中\\
-o消息文件=$ trace_file.msgTLS =汽车的用户名= $ smtp_username \\
密码=$(解密$ smtp_password参数))
I'm a terrible beginner at bash scripting, and am hoping someone can help me out with this issue.
Having a problem with the Prey project standalone scripts. There's a line that's supposed to send an email, and apparently its not formatted correctly.
response=`mailsender -f "$mail_from" -t "$mail_to" -u "$complete_subject" \
-s $smtp_server -a $file_list -o message-file="$trace_file.msg" \
tls=auto username=$smtp_username \
password=\`decrypt \"$smtp_password\"\``
Where mailsender is an alias to Brandon Zehm's PERL sendEmail script, $smtp_password is a pointless base64 encoding of the password, and decrypt is:
decrypt() {
echo "$1" | openssl enc -base64 -d
}
So can anyone tell me what's wrong with the script? For reference, if I just replace the entire decrypt part with the plaintext password, it works fine. i.e.:
response=`mailsender -f "$mail_from" -t "$mail_to" -u "$complete_subject" \
-s $smtp_server -a $file_list -o message-file="$trace_file.msg" \
tls=auto username=$smtp_username password=actual_password`
The simplest thing to do is avoid backticks, and use $()
instead -- they nest cleanly, with no special escaping needed:
response=$(Documents/Projects/Shell\ Scripting/printargs -f "$mail_from" \
-t "$mail_to" -u "$complete_subject" -s $smtp_server -a $file_list \
-o message-file="$trace_file.msg" tls=auto username=$smtp_username \
password="$(decrypt "$smtp_password")")
这篇关于在preY项目bash脚本格式不正确?嵌套反引号的问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!