PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > linux.debian.user > How to send mails with attachments for each file in a directory ?
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
linux.debian.user debian-user@lists.debian.org.

How to send mails with attachments for each file in a directory ?

Réponse
 
LinkBack Outils de la discussion
Vieux 29/01/2008, 17h00   #1
Jabka Atu
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut How to send mails with attachments for each file in a directory ?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Good day,..


since i can't send find a fast way to send many pictures to Gmail /
ISP mail (Quata limit for single mail).

I thought it will be fun to do it in one line :

find *.jpg -exec uuencode '{}' '{}' | mail someone@gmail.com \;

but this won't work since :


find: missing argument to `-exec'

No message, no subject; hope that's ok
Can't send mail: sendmail process failed with error code 1


when working with only one file :

uuencode file.jpg file.jpg | mail someone@gmail.com \;


this works perfectly.

- --
- --
Could you at least use man ?
Jabka Atu (aka mha13/Mashrom Head) || bsh83.blogspot.com
- --
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iQIVAwUBR59b+m9p6JnF9I1qAQLUsg/+K2rrZIDJN2o075mpgThZBUA+PHdR8u6U
BD+acWDWCYYghhb4zl5WbylAOQJxsAJf//RmN61ErbDCcWoCWP+Jh2NY32hsSQni
V0CcVL2M6Z276T89WlPjzsPZGylHURnkgixNozGSmY1d240Kj5 PbDhDQdAs1AiQ2
zbo2ohb+pTpgV0uaY9JOG4WMn5D2zw8cF0CI0NjH17YyaGMgra tvoK057Lw4k4pC
xMCLouSa861Z6HGAljq5F8rIxMpMHdU1v42b+2ZZzlVDVwHntW aS43ApIgihfkc4
YS7p+RWpvkT1XEAduBgB/N7Ufzhua5BtnIZyPsRdPQIaM6WYU6nbl+iBIErUNVYr
JDIt9luJMSDd5xdTdFTHTB0KolIcaRYfS5Y+lDluV/1ahWJht0LG6W7rg+o3eExy
RM1eS8qr44qCXEaJjlki/JnTgsE1xfDgaZdx9NJMoTsLI9wM6tC1C22Kj1IBUMWc
zJx0QPQ7iYqWUIi0yC5UWV7+9u+n8E1REotBLdXgNd33/G91Qhz6Fp4Hy4xdaVs7
uDlq7EQKTVgOiJPMgyANoqYNxVk3HMLSFMWOn/C6HSjpmthDtbAwOFGX7+mRfk6k
ysSsCLo2RKWMJjQy70wLDVVxFhoQtV78qqmhgTEnCtnPK61VEj ucqgUKORyHryXy
IZPI/fcJ3rE=
=wkBN
-----END PGP SIGNATURE-----


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
  Réponse avec citation
Vieux 29/01/2008, 17h30   #2
Douglas A. Tutty
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How to send mails with attachments for each file in a directory ?

On Tue, Jan 29, 2008 at 07:01:47PM +0200, Jabka Atu wrote:
> find *.jpg -exec uuencode '{}' '{}' | mail someone@gmail.com \;
>
> but this won't work since :
>
> find: missing argument to `-exec'
>
> No message, no subject; hope that's ok
> Can't send mail: sendmail process failed with error code 1
>
> when working with only one file :
>
> uuencode file.jpg file.jpg | mail someone@gmail.com \;
>
> this works perfectly.


Could you throw xargs into the pipeline somewhere? It runs a command
once for each line of input.

Doug.


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
  Réponse avec citation
Vieux 29/01/2008, 17h40   #3
Jabka Atu
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How to send mails with attachments for each file in a directory ?

I will check this abit later for now i used :
~/cat sender
#!/bin/bash

uuencode $1 $1 | mail -s Re:pictures someone@gmail.com

and on console :

~/ find *.jpg -exec sender '{}' \;

it is an ugly but abit working solutione but a user can't see it on gmail
(only with client he can see the attachments (icedove) ).


On Jan 29, 2008 7:22 PM, Douglas A. Tutty <dtutty@porchlight.ca> wrote:

> On Tue, Jan 29, 2008 at 07:01:47PM +0200, Jabka Atu wrote:
> > find *.jpg -exec uuencode '{}' '{}' | mail someone@gmail.com \;
> >
> > but this won't work since :
> >
> > find: missing argument to `-exec'
> >
> > No message, no subject; hope that's ok
> > Can't send mail: sendmail process failed with error code 1
> >
> > when working with only one file :
> >
> > uuencode file.jpg file.jpg | mail someone@gmail.com \;
> >
> > this works perfectly.

>
> Could you throw xargs into the pipeline somewhere? It runs a command
> once for each line of input.
>
> Doug.
>
>
> --
> To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
> with a subject of "unsubscribe". Trouble? Contact
> listmaster@lists.debian.org
>
>


  Réponse avec citation
Vieux 29/01/2008, 17h50   #4
Tzafrir Cohen
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How to send mails with attachments for each file in a directory ?

On Tue, Jan 29, 2008 at 07:01:47PM +0200, Jabka Atu wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Good day,..
>
>
> since i can't send find a fast way to send many pictures to Gmail /
> ISP mail (Quata limit for single mail).


There are a number of command-line mailiers that support
striaght-forward MIME attachments. I normally use mutt. There is also
heirloom-mailx (previously 'nail'), there is biabam, which is a small
bash script, and a bunch of others.

So there's really no need to stick with the one legacy client that does
not support attachments.

Also, if you use gmail's imap support, you can probably copy messages
directly to imap folders.

It has been common in the past due to such limitations to split a large
mail message to partial messages and regroup them together. I recall
that this is even still supported on Outlook Express.

--
Tzafrir Cohen | tzafrir@jabber.org | VIM is
http://tzafrir.org.il | | a Mutt's
tzafrir@cohens.org.il | | best
ICQ# 16849754 | | friend


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
  Réponse avec citation
Vieux 29/01/2008, 23h30   #5
Andrew Reid
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How to send mails with attachments for each file in a directory ?

On Tuesday 29 January 2008 12:01, Jabka Atu wrote:
> Good day,..
>
>
> since i can't send find a fast way to send many pictures to Gmail /
> ISP mail (Quata limit for single mail).
>
> I thought it will be fun to do it in one line :
>
> find *.jpg -exec uuencode '{}' '{}' | mail someone@gmail.com \;
>
> but this won't work since :
>
>
> find: missing argument to `-exec'


I think you're using "find" wrong. On my (debian "stable") system,
in a randomly selected directory, I get:

> # find *.jpg
> find: *.jpg: No such file or directory


... versus

> # find . -name "*.jpg"
> [big list of files]



Try that.

-- A.
--
Andrew Reid / reidac@bellatlantic.net


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
  Réponse avec citation
Vieux 30/01/2008, 01h00   #6
Ken Irving
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How to send mails with attachments for each file in a directory ?

On Tue, Jan 29, 2008 at 06:27:44PM -0500, Andrew Reid wrote:
> On Tuesday 29 January 2008 12:01, Jabka Atu wrote:
> > Good day,..
> >
> >
> > since i can't send find a fast way to send many pictures to Gmail /
> > ISP mail (Quata limit for single mail).
> >
> > I thought it will be fun to do it in one line :
> >
> > find *.jpg -exec uuencode '{}' '{}' | mail someone@gmail.com \;


This (but see below for the trailing \; thing and uuencode syntax):

find *.jpg -exec uuencode '{}' '{}' \; | mail someone@gmail.com \;

or this,

find *.jpg -exec uuencode '{} {};' | mail someone@gmail.com \;

ought to work. For that matter, the bash shell won't mess with the {}
characters, so they don't even need to be quoted. I'd generally do
it like:

find *.jpg -exec uuencode {} {} \; | mail someone@gmail.com \;

> > but this won't work since :
> >
> > find: missing argument to `-exec'

>
> I think you're using "find" wrong. On my (debian "stable") system,
> in a randomly selected directory, I get:
>
> > # find *.jpg
> > find: *.jpg: No such file or directory

>
> ... versus
>
> > # find . -name "*.jpg"
> > [big list of files]


find is a useful and powerful utility, but it's particular about getting
command line arguments in the way it understands. Hard to blame it
for that, but the syntax may be confusing; I know it took me a while
to get it figured out (as far as I have) by reading and rereading the
manpage and/or info docs, and maybe looking for something like a Linux
Journal article on the subject. Don't overlook find -h or find --,
if that works, as often the '' info provided that way is very concise,
if not exhaustive.

It should probably be noted that the syntax details may well vary
between different finds in Linux/Unix distributions, sometimes even
between versions of the same one, but in all cases the installed
and manpages will (well, should) define the syntax. If you're using
find with busybox you'll need to look at those docs to see what to do.

I find find very useful, and find's -exec command as well, but someone
always chimes in with how it's "wrong" to use it since it causes find to
create umpteen shell processes, one for each hit, and you really should be
piping find into xargs. Whatever. I use xargs a lot too, but I figure
my computer's generally just sitting there spinning its wheels anyway,
and I'm doing it a favor by giving it something to do :-). I read into
those arguments the assumption that the computer is serving zillions of
web queries or doing other real work, but that's not always the case.

Besides find, don't overlook some of the shell loop constructs or ways
to use subshells. I'm not sure, but the following might do the same as
what you're doing above:

for f in *.jpg; do uuencode $f $f; done | mail someone@gmail.com

Actually, I now see that you've got \; at the end of the mail command,
so maybe you want to mail each one? I'm not sure of doing that in find,
and dimly recall fighting and failing with trying to pipe inside a find
-exec construct. This is easy to do with a shell loop, e.g.,

for f in *.jpg; do "uuencode $f $f | mail someone@gmail.com"; done

(Sigh, for all this I assumed uuencode is running as a filter, which somehow
I doubt, given the two filenames given. I think you'll want to use a single
argument to get the output to stdout.)

Ken

--
Ken Irving, fnkci+debianuser@uaf.edu


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
  Réponse avec citation
Vieux 30/01/2008, 11h10   #7
Dan H.
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How to send mails with attachments for each file in a directory ?

On Tue, Jan 29, 2008 at 03:48:27PM -0900, Ken Irving wrote:

> I find find very useful, and find's -exec command as well, but someone
> always chimes in with how it's "wrong" to use it since it causes find to
> create umpteen shell processes, one for each hit, and you really should be
> piping find into xargs.


My favorite way is to use find's -printf directive to construct the complete
commands and pipe the result to a shell. Has the advantage that you first
hack away at your complete find commend and give it a dry run, and if you're
happy with what it spits out you just tack the "| sh" bit to the end.

--D.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFHoDSkGdM4FB223AcRAi2GAJ0ZCGX4Tu+uwG1LhLQVQ7 DXM5c6QgCcCAZ9
6R05UzYD/QQCH0xUWnquOAE=
=nNpd
-----END PGP SIGNATURE-----

  Réponse avec citation
Vieux 30/01/2008, 13h50   #8
Martin Marcher
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How to send mails with attachments for each file in a directory ?

On 2008-01-30 09:26:12, Dan H. wrote:
> My favorite way is to use find's -printf directive to construct the complete
> commands and pipe the result to a shell. Has the advantage that you first
> hack away at your complete find commend and give it a dry run, and if you're
> happy with what it spits out you just tack the "| sh" bit to the end.


Now, _that_ is a tip i wish I head read earlier, guess it also plays
really well with akward input like stuff you need to escape as you can
simply look at what it will do before killing a lot of stuff.

martin



--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
  Réponse avec citation
Vieux 30/01/2008, 15h40   #9
Daniel Burrows
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How to send mails with attachments for each file in a directory ?

On Tue, Jan 29, 2008 at 07:01:47PM +0200, Jabka Atu <mashrom.head@gmail.com> was heard to say:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Good day,..
>
>
> since i can't send find a fast way to send many pictures to Gmail /
> ISP mail (Quata limit for single mail).
>
> I thought it will be fun to do it in one line :
>
> find *.jpg -exec uuencode '{}' '{}' | mail someone@gmail.com \;
>
> but this won't work since :
>
>
> find: missing argument to `-exec'


The pipe is being interpreted by the shell, so find never sees the
trailing semicolon, hence the error you get.

If you want to do this, you can try:

find $PATH *.jpg -exec sh -c 'uuencode "$0" "$0" | mail someone@gmail.com' '{}' ';'

which ought to do what you want. You need to explicitly invoke a
shell because find will just pass the pipe character literally along
instead of interpreting it.

Daniel


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
  Réponse avec citation
Vieux 31/01/2008, 09h20   #10
Magnus Therning
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: How to send mails with attachments for each file in a directory ?

Jabka Atu wrote:
> Good day,..
>
>
> since i can't send find a fast way to send many pictures to Gmail /
> ISP mail (Quata limit for single mail).
>
> I thought it will be fun to do it in one line :
>
> find *.jpg -exec uuencode '{}' '{}' | mail someone@gmail.com \;


I think you're using `find` wrong. AFAIK find takes a directory first,
then some filter statements and lastly a “commandâ€. Thatmeans I'd
write the first part of the `find` portion like this:

find . -name \*.jpg ...

But I'm not convinced `find` is the best thing to use in this case. If
all files to be mailed are in the current directory I would personally
have used a `for` loop:

for f in *.jpg; do uuencode $f $f | mail someone@gmail.com; done

Just my 2p.

/M

--
Magnus Therning (OpenPGP: 0xAB4DFBA4)
magnusï¼therning.org Jabber: magnus.therningï¼gmail.com
http://therning.org/magnus

What if I don't want to obey the laws? Do they throw me in jail with
the other bad monads?
-- Daveman


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFHoZH0iMWTaatN+6QRAjG1AKClr2TOb7j1t97LmYrPrg V0rEPrfgCg5FN0
mEB97DO2qfUI3NeMnL34LCI=
=VXxC
-----END PGP SIGNATURE-----

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 07h05.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,26767 seconds with 18 queries