Jump to content

Using mail in a bash script


Recommended Posts

I'm writing a bash script to backup some machines and eventually I want it to become a cron job (but thats a different story).

 

I basically want to use mail (or something similar) to send a message to my user along the lines that the backup was complete. Does anyone have any experience of doing this?

 

Thanks,

Link to comment
Share on other sites

assuming your machine has access to a working mail server, its all pretty straight forward. i used it once to send simple mail messages. i even experimented doing some attachments via uuencode. and its all command-line. i tried doing a distributed.net send and receive script but i left my previous job before i can fullfill it. i was able to do the send part though. :)

 

ciao!

Link to comment
Share on other sites

I think sendmail is configured on the boxen I want it to be, to the point that I can send a test mail via the command line. I have no idea how to specify what text is actually sent via mail though. For example if I use the command line:

 

# mail -s Foo root

Bar

Ctrl-D

CC:

#

 

works, but obviously as part of a shell script

 

mail -s Foo root

Bar

.

 

does not work. Any ideas how I can specify the body of the mail?

 

Thanks,

Link to comment
Share on other sites

you need to specify everything in one line. sorry im not in a linux box (if you see me online now its probably from a windows box as i dont have net at home) but everything is in the manpage.

 

when i get some free time ill try to do it in cygwin if there is a port.

 

ciao!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...