LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 08-29-2016, 04:16 PM   #1
Symbiot78
LQ Newbie
 
Registered: Aug 2016
Posts: 2

Rep: Reputation: Disabled
mutt - send attachment with specific file | file shows 0 bytes


ok, so I'm going out of my mind.

I'm trying to send an email attachment I generate from a find command.
it does indeed send the email with the attachment but the file is empty..

the command is as follows:

Code:
find /media/2A06DF4A06DF1623/media/limited\ time\ only/ -mindepth 1 -maxdepth 1 -type d -mtime +120 -printf "%f\n" > /tmp/file.txt | mutt -s "to be deleted" myemail@gmail.com -a /tmp/file.txt
the above generates the 0 byte email attachment

If I go to /tmp and view the file.txt I see a 4Kb file with contents.

If I create a filed with a few chars.... say fish.txt and use the following:

Code:
find /media/2A06DF4A06DF1623/media/limited\ time\ only/ -mindepth 1 -maxdepth 1 -type d -mtime +120 -printf "%f\n" > /tmp/file.txt | mutt -s "to be deleted" myemail@gmail.com -a /tmp/fish.txt
(yes I know it generates file.txt and I send fish.txt)
then I get content in the attachment...
So I am thinking it must somehow be the file itself.. but I cannot spot the problem...

anyone have any ideas?
 
Old 08-30-2016, 08:58 AM   #2
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,453

Rep: Reputation: 447Reputation: 447Reputation: 447Reputation: 447Reputation: 447
Hi

The | character looks strange. First you send output to a file, then to the mutt command. I think mutt will send the mail before the find command is finished. Try a ; instead.

Code:
find /media/2A06DF4A06DF1623/media/limited\ time\ only/ -mindepth 1 -maxdepth 1 -type d -mtime +120 -printf "%f\n" > /tmp/file.txt ; mutt -s "to be deleted" myemail@gmail.com -a /tmp/file.txt
 
Old 08-30-2016, 09:13 AM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,700

Rep: Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895
Don't use the pipe (|). Run it as two separate commands.
Code:
find /media/2A06DF4A06DF1623/media/limited\ time\ only/ -mindepth 1 -maxdepth 1 -type d -mtime +120 -printf "%f\n" > /tmp/file.txt; mutt -s "to be deleted" myemail@gmail.com -a /tmp/file.txt
Or pipe it directly without saving to file.
Code:
find /media/2A06DF4A06DF1623/media/limited\ time\ only/ -mindepth 1 -maxdepth 1 -type d -mtime +120 -printf "%f\n" | mutt -s "to be deleted" myemail@gmail.com
It is the file itself. Since > redirects to the file.txt file there is nothing on stdout that gets piped to the mutt command. Since > will erase the existing contents it appears as an empty file.

Another option would be to use the tee command but you don't need to pipe and have an attachment concurrently.
 
Old 08-30-2016, 12:27 PM   #4
Symbiot78
LQ Newbie
 
Registered: Aug 2016
Posts: 2

Original Poster
Rep: Reputation: Disabled
hi guys

thx for this... I got it working..

I used this solution:
Code:
find /media/2A06DF4A06DF1623/media/limited\ time\ only/ -mindepth 1 -maxdepth 1 -type d -mtime +120 -printf "%f\n" > /tmp/file.txt; mutt -s "to be deleted" myemail@gmail.com -a /tmp/file.txt

but I had to do this to automate it completely:

Code:
find /media/2A06DF4A06DF1623/media/limited\ time\ only/ -mindepth 1 -maxdepth 1 -type d -mtime +120 -printf "%f\n" > /tmp/file.txt; mutt -s "to be deleted" myemail@gmail.com -a /tmp/file.txt < /tmp/body.txt
if I omit the < /tmp/body.txt mutt opens it's mailsend options and ask for email recipient, body text etc etc. but adding a dummy body.txt file works
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] need help w/script using variable to send attachment via mutt thealmightyos Linux - Software 1 09-10-2014 06:18 PM
Can't send file attachment with curl patapout Linux - Newbie 0 08-10-2012 04:34 PM
[SOLVED] mutt didn't send email via .sh file after reboot anon091 Linux - Newbie 4 05-14-2010 09:37 AM
How to send a html file as an file attachment to my mail from crontab? GRD Linux - Newbie 2 06-03-2008 11:39 AM
mutt zipped file name attachment ??? dainovka Linux - Software 0 03-16-2005 01:00 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:25 AM.

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