Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Note: I use tcsh.

I am trying make an alias that will use the mutt command to send an email with a pre-written body and subject line but that will take the alias argument and attach it to the email. The best I currently have is:

alias emailattach 'echo "Message Body" | mutt -a \!:1 -s "Subject" email@somewhere.com'

This alias sets just fine, without any whining, but when I try to run it I get the following message:

Can't stat email@somewhere.com: No such file or directory
email@somewhere.com: unable to attach file.

When I remove -a \!:1 I no longer get the error message, so I believe the problem could be focused on this portion of the alias. The files I've told emailattach to attach are real, attachable files (a PDF specifically), so that's not the issue.

I also tried the same alias but without the single quotes and I only got this error:

email@somewhere.com: unable to attach file.

To see if the pipeline was the crux of the problem I tried the following:

alias emailattach mutt -a \!:1 -s "Subject" email@somewhere.com

and then tried just running:

echo "Message Body" | emailattach /path/to/attachment

which gave the same error message as I first listed(can't stat...unable to attach file.). However, when I just ran:

echo "Message Body" | emailattach 

I got this error:

Bad ! arg selector.

Which I assume is just an error saying that I forgot to put in the required argument.

What have I written wrong in my alias that makes it not work?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Try changing your alias around so that the attachment is last in your call to mutt like so:

$ alias emailattach 'echo "Message Body" | mutt -s "Subject" email@somewhere.com -a \!:1'

Doing it this way worked for me.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.