command to email from the terminal


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers command to email from the terminal
# 1  
Old 04-09-2009
command to email from the terminal

I have a script, myscript.sh that I need the output to be sent by email to bernadette@email.com bill@email.com and will@email.com . How do I go about making this happen?

I am using the Macintosh Operating system with Entourage 2008 as my email client, but I would fine just doing this in the true Unix fashion. sendmail? I also need to have this run every Monday, but the schedule part I can figure out, however if someone wants to go the extra mile, I am happy to see their solution. Thanks so much!
# 2  
Old 04-09-2009
Im using this on unix and linux, but it may work on Mac OS.

I have a script called: mailme.sh:
Code:
ATTFILE=$1
ATTNAME=$1
MAILTO="bernadette@email.com, bill@email.com, will@email.com"
MAILFROM=whoever@email.com

( cat <<HERE; uuencode "${ATTFILE}" "${ATTNAME}" ) | sendmail -oi -t
From: ${MAILFROM}
To: ${MAILTO}
Subject: gles9016 attached $ATTNAME

HERE

I would do the following:

1) Send the output of "myscripts.sh" to /tmp/myscript.txt
2) call: mailme.sh /tmp/myscript.txt

This ATTACHES the /tmp/myscript.txt to the email.
# 3  
Old 04-09-2009
You could also use mailx:

Echo the output from myscript.sh to a text file then execute mailx against that file like so:

Code:
mailx -s "subjectline" bernadette@email.com bill@email.com will@email.com < /temp/outputfromscript.txt

This will send an email with the subjectline and the contents of the outputfromscript.txt as the body to the listed people. You may have to put commas between the intended recipients...I'm not sure.
# 4  
Old 04-09-2009
Awesome mcthick!
# 5  
Old 04-09-2009
ty Smilie Glad it helped.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Linux

Terminal command

I need to execute apt-cdrom to designate the pendrive using LM 18.3x 'live". (instead of CD-Rom) Rick (7 Replies)
Discussion started by: 69Rixter
7 Replies

2. Shell Programming and Scripting

Execute ssh command with additional terminal command to any remote user not working script

Hello i am having an issue with bash script and this is the code now=$(cat hosts1.txt | awk '{print $2;}') while read n ;do ssh root@$now 'useradd test1; echo -e "test1\ntest1" | passwd test1 && echo "test1 ALL=(ALL:ALL) ALL" >> /etc/sudoers' When i execute only part with cat, it... (8 Replies)
Discussion started by: tomislav91
8 Replies

3. Shell Programming and Scripting

Using top command to email if process is exceeding 25% and sending an email alert if so

This is my first time writing a script and Im having some trouble, Im trying to use the top command to monitor processes and the amount of CPU usage they require, my aim is to get an email if a process takes over a certain percentage of CPU usage I tried grep Obviosly that hasnt worked, Any... (8 Replies)
Discussion started by: jay02
8 Replies

4. OS X (Apple)

Help: Add email users in OSX terminal

Please forgive me if this is the wrong place to post. I am a VERY basic user here and have been tasked with adding a user to our email system -- we use a squirrelmail interface and I have root passwords etc. I tried logging in through a browser but get this error: ERROR: Connection... (1 Reply)
Discussion started by: dperro01
1 Replies

5. UNIX for Dummies Questions & Answers

Help: Add email users in OSX terminal

Please forgive me if this is the wrong place to post. I am a VERY basic user here and have been tasked with adding a user to our email system -- we use a squirrelmail interface and I have root passwords etc. I tried logging in through a browser but get this error: ERROR: Connection dropped... (1 Reply)
Discussion started by: dperro01
1 Replies

6. Shell Programming and Scripting

Is command line invocation of gnome-terminal to run more than one command possible?

Hello, I am trying to learn how to pass something more than a one-command startup for gnome-terminal. I will give an example of what I'm trying to do here: #! /bin/bash # #TODO write this for gnome and xterm USAGE=" ______________________________________________ ${0##*/} run... (0 Replies)
Discussion started by: Narnie
0 Replies

7. OS X (Apple)

Automated Terminal Command Help

Is there a command that someone could help me with, that would automate me having to: 1. Go into multiple different folders (probably around 100) 2. Check and see if there are either 1(+) subfolders within that 3. If there are, check and see if there are either 1(+) .m4a / .m4p / .m4v files... (3 Replies)
Discussion started by: qcom
3 Replies

8. UNIX for Dummies Questions & Answers

what's the terminal command to do this ?

what's the terminal command to do this ? thanks (6 Replies)
Discussion started by: aneuryzma
6 Replies

9. UNIX for Dummies Questions & Answers

Plz Help : How to use write command to execute command on some other terminal

Hi Group , I m trying to execute commands on some other system using write command but inspite of executing the commands they r passed as simple messages. - i m writing >write user-id ! ls o ctrl-d inspite of executing the command ls,other terminal shows ! ls. Thnx in advance. (2 Replies)
Discussion started by: Aashish
2 Replies

10. UNIX for Dummies Questions & Answers

Send email from unix terminal on Mac OS 10.x

Hello, I want to send email from unix terminal on Mac OS 10.x. I have 2 user accounts on the system - userOne and root. I tried sending an email from userOne to root by entering "mail root". It prompts to enter Subject and the content. It doesn't give any error message, but root doesn't get... (0 Replies)
Discussion started by: hypamw
0 Replies
Login or Register to Ask a Question