gpt4 book ai didi

linux - 如何将电子邮件添加到此脚本

转载 作者:太空宇宙 更新时间:2023-11-04 11:52:51 25 4
gpt4 key购买 nike

如果文件传输成功“传输成功”或者文件有问题“有问题”,我需要了解如何添加电子邮件通知......我做错了什么.. .这是我在文件传输后收到的消息

sftp> invalid command name "EOD"  
while executing
"EOD"

#!/usr/bin/expect<<EOD > output.log
#
spawn sftp -o Port=22 HOSTDNS@HOSTDNS.com
expect "assword:"
send "password\r"
expect "sftp>"
send "lcd /usr/lib/basic/TEMP/TRANS\r"
expect "sftp>"
send "cd /home/denni/STORAGE\r"
expect "sftp>"
send "mput *\r"
expect "sftp>"
send "bye\r"
EOD
RC=$?
if [[ ${RC} -ne 0 ]]; then
cat output.log | mail -s "Errors Received"
"username@somewhere.com"
else
echo "Success" | mail -s "Transfer Successful"
"username@somewhere.com "
fi

最佳答案

确保脚本顶部有 bash,并且 EOD 后没有任何空格。这对我有用。请注意,我删除了 #!也从 expect 二进制文件的开头。

#!/bin/bash

/usr/bin/expect <<EOD > output.log
spawn sftp username@hostname
expect "assword:"
send "password\r"
expect "sftp>"
send "ls\r"
expect "sftp>"
send "bye\r"
EOD

关于linux - 如何将电子邮件添加到此脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55524341/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com