LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-22-2016, 11:24 AM   #1
Entropy1024
Member
 
Registered: Dec 2012
Location: UK
Distribution: Ubuntu 16 & 17
Posts: 131

Rep: Reputation: Disabled
Sending text from file to SSMTP


I'm trying to get a bash script to search a text file in a certain folder and if it finds the number 192 in that file it then emails me the result of the grep. Script is as follows:

Code:
#!/bin/bash
PINGFILE="/home/tim/Documents/p5e/p5e_status/p5e_ping/*.txt"
if grep 192 $PINGFILE ; then
        grep 192 $PINGFILE >> wfound.txt
        ssmtp -vvv myemail@gmail.com < wfound.txt
fi
When I run the script it generates a file called wfound.txt fine with all the instances of 192. I also get an email OK, however there is nothing in it.

Where am I going wrong?

Many thanks
Tim
 
Old 04-23-2016, 06:05 AM   #2
descendant_command
Senior Member
 
Registered: Mar 2012
Posts: 1,876

Rep: Reputation: 643Reputation: 643Reputation: 643Reputation: 643Reputation: 643Reputation: 643
https://wiki.archlinux.org/index.php...#Sending_Email
 
Old 04-23-2016, 06:59 AM   #3
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,912

Rep: Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513Reputation: 1513
Might be the wrong tool...

You might actually want to use mail - as in "mail myemail@gmail.com < wfound.txt"

You might also want to include a subject heading (-s option)
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Sending Escape Codes to a Printer within a Plain Text File tiuz Linux - Hardware 5 02-17-2018 09:37 AM
ssmtp sends as email attachment instead of body text rukmeister Linux - Newbie 1 05-06-2013 09:26 AM
how to attach a file to a sending mail with ssmtp golden_boy615 Linux - Networking 3 01-02-2012 03:16 PM
sending html text message with zip file attachment; Content-Type: multipart/mixed phelpsj Programming 1 06-22-2006 08:50 AM
sending data to standard out and to a text file at the same time. liguorir Linux - Software 1 08-23-2005 12:14 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:54 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration