通过电子邮件发送shell脚本eval结果

时间:2014-04-25 12:22:14

标签: shell email rsync

这个问题来自我自己对previous questions之一的回答。我给那里的剧本工作得很好。为了解决这个问题,我想获取 eval'd rsync结果并将其通过电子邮件发送给我们。我不知道应该怎么做。

更新

在回答评论时,我在这个问题中提供了更多细节。有问题的剧本复制了我自己对其他问题的回答:

#! /bin/bash
# Backup to EVBackup Server

local="/var/lib/automysqlbackup/daily/dbname"
#replace dbname as appropriate

svr="$(uname -n)"
remote="$(svr/.example.com/)"
#strip out the .example.com bit to get the destination folder on the remote server
remote+="/"

evb="user@user.evbackup.com:"
#user will have to be replaced with your username
evb+=$remote

cmd='rsync -avz -e "ssh -i /backup/ssh_key" '
#your ssh key location may well be different

cmd+=$local
cmd+=$evb
#at this point cmd will be something like
#rsync -avz -e "ssh -i /backup/ssh_key" /home bob@bob.evbackup.com:home-data

eval $cmd

从终端运行此脚本时,您会看到Rsync命令的输出。我希望能够做的是将输出抓取到shell变量中,然后通过电子邮件将其发送出去,这样我就可以让人们了解在执行Rsync时可能遇到的任何问题。

我想我将能够弄清楚如何从shell脚本发送电子邮件。令我难过的是我如何捕获该电子邮件的有效负载 - 即Rsync输出。

0 个答案:

没有答案
相关问题