|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hi,
Currently, I send the contents of a file by mail by typing: mail someone@somewhere.com < some.file But I can't type my own message using the above command to send with the file. I checked the command line options for mail and there doesn't seem to be an attachment parameter. Does anyone know how I can do this through the command line? Thanks. |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
"yusuf" <yusufm@gmail.com> writes:
> Currently, I send the contents of a file by mail by typing: > > mail someone@somewhere.com < some.file > > But I can't type my own message using the above command to send with > the file. I checked the command line options for mail and there doesn't > seem to be an attachment parameter. Does anyone know how I can do this > through the command line? Take a look at Shelldorado it has scripts to do things like that. http://www.shelldorado.com/ Joe |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
On 2006-08-20, yusuf wrote:
> Hi, > > Currently, I send the contents of a file by mail by typing: > > mail someone@somewhere.com < some.file > > But I can't type my own message using the above command to send with > the file. I checked the command line options for mail and there doesn't > seem to be an attachment parameter. Does anyone know how I can do this > through the command line? { cat ## read stdin cat some.file } | mail someone@somewhere.com -- Chris F.A. Johnson, author <http://cfaj.freeshell.org> Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress) ===== My code in this post, if any, assumes the POSIX locale ===== and is released under the GNU General Public Licence |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
yusuf wrote:
> Currently, I send the contents of a file by mail by typing: > > mail someone@somewhere.com < some.file > > But I can't type my own message using the above command to send with > the file. I checked the command line options for mail and there doesn't > seem to be an attachment parameter. Does anyone know how I can do this > through the command line? You have to either built whole MIME message (with all boundaries and everything) and pipe it to /usr/bin/mail (or directly to /usr/sbin/sendmail -- after all, when you built it all yourself there is not much mail can do for you). The other way would be to use some other mail replacement -- nail is 100% replacement of mailx and it can do (among other things) attachments. Matěj -- GPG Finger: 89EF 4BC6 288A BF43 1BAB 25C3 E09F EF25 D964 84AC http://www.ceplovi.cz/matej/blog/, Jabber: ceplma@jabber.cz 23 Marion St. #3, (617) 876-1259, ICQ 132822213 As a rule of thumb, the more qualifiers there are before the name of a country, the more corrupt the rulers. A country called The Socialist People's Democratic Republic of X is probably the last place in the world you'd want to live. -- Paul Graham discussing (not only) Nigerian spam (http://www.paulgraham.com/spam.html) |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
Le Sat, 19 Aug 2006 22:20:00 -0400, Chris F.A. Johnson a écrit:
> On 2006-08-20, yusuf wrote: >> Hi, >> >> Currently, I send the contents of a file by mail by typing: >> >> mail someone@somewhere.com < some.file >> >> But I can't type my own message using the above command to send with >> the file. I checked the command line options for mail and there doesn't >> seem to be an attachment parameter. Does anyone know how I can do this >> through the command line? > > { > cat ## read stdin > cat some.file > } | mail someone@somewhere.com That's OK as the OP seems to send 7bit files (thru direct mail <) but here's an idea of a small complement in case you have binaries. I know it is dirty and it would be much better to use mimencode than UUE but, that's for desperates cases where you don't have metamail and you can't install them :-) (besides if you have had metamail you would have used it instead of this blob ;-) ------------- $ cat mailx_in_shell #!/bin/sh ### Badfile () { printf "\n\n File ${1} is empty or missing ...\n\n" exit 2 } Usage () { printf "\n\n Usage: $0 adressee attachment\n\tType your message then Ctrl-D\n\n" exit 1 } ### [ $# -gt 1 ] || Usage attachment="${2}" adressee=${1} sender="youlegaladdress@yourelayabledomain" ### [ -s "${attachment}" ] || Badfile "${attachment}" ### ### This is if you post plaintext and dont need to send a binary ### ( printf "\n" && cat && cat "${attachment}" ) | /usr/lib/sendmail -v -f ${sender} ${adressee} ### ( printf "\n" && cat && printf "\n" && uuencode "${attachment}" "${attachment}" ) \ | /usr/lib/sendmail -v -f ${sender} ${adressee} ------------- |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
On Sun, 20 Aug 2006 09:57:10 -0400, Matej Cepl wrote:
> You have to either built whole MIME message (with all boundaries and > everything) and pipe it to /usr/bin/mail (or directly > to /usr/sbin/sendmail -- after all, when you built it all yourself there is > not much mail can do for you). The other way would be to use some other > mail replacement -- nail is 100% replacement of mailx and it can do (among > other things) attachments. Handy! Thx. M4 -- Ah, the beauty of OSS. Hundreds of volunteers worldwide volunteering their time inventing and implementing new, exciting ways for software to suck. -- Toni Lassila in the Monastry |
|
![]() |
| Outils de la discussion | |
|
|