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 [EMAIL PROTECTED] \; I think you're using `find` wrong. AFAIK find takes a directory first, then some filter statements and lastly a “command”. That means 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 [EMAIL PROTECTED]; 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 signature.asc Description: OpenPGP digital signature
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 <[EMAIL PROTECTED]> 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 [EMAIL PROTECTED] \; > > 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 [EMAIL PROTECTED]' '{}' ';' 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 [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
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 [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
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. signature.asc Description: Digital signature
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 [EMAIL PROTECTED] \; This (but see below for the trailing \; thing and uuencode syntax): find *.jpg -exec uuencode '{}' '{}' \; | mail [EMAIL PROTECTED] \; or this, find *.jpg -exec uuencode '{} {};' | mail [EMAIL PROTECTED] \; 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 [EMAIL PROTECTED] \; > > 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 --help, if that works, as often the 'help' 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 help 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 [EMAIL PROTECTED] 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 [EMAIL PROTECTED]"; 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, [EMAIL PROTECTED] -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
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 [EMAIL PROTECTED] \; > > 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 / [EMAIL PROTECTED] -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
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 | [EMAIL PROTECTED] | VIM is http://tzafrir.org.il || a Mutt's [EMAIL PROTECTED] || best ICQ# 16849754 || friend -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
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 [EMAIL PROTECTED] 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 <[EMAIL PROTECTED]> wrote: > On Tue, Jan 29, 2008 at 07:01:47PM +0200, Jabka Atu wrote: > > find *.jpg -exec uuencode '{}' '{}' | mail [EMAIL PROTECTED] \; > > > > 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 [EMAIL PROTECTED] \; > > > > 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 [EMAIL PROTECTED] > with a subject of "unsubscribe". Trouble? Contact > [EMAIL PROTECTED] > >
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 [EMAIL PROTECTED] \; > > 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 [EMAIL PROTECTED] \; > > 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 [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]