LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Correct syntax to pipe to gpg and then mail the result... (https://www.linuxquestions.org/questions/linux-newbie-8/correct-syntax-to-pipe-to-gpg-and-then-mail-the-result-683384/)

curtisa 11-14-2008 10:24 AM

Correct syntax to pipe to gpg and then mail the result...
 
Hi,
With my email hoster I have the ability to pipe incoming emails to a program (as opposed to immediately forwarding to another address) and what I would like to do is first pipe to gpg to encrypt the mail and then mail it on to another address.

so far what I've tried is ...

Code:

#!/bin/bash
## /usr/bin/gpg -ea -r me@mydomain.com -o - $1 | mail -s Test1 me@mydomain.com
cat > /usr/bin/gpg -ea -r me@mydomain.com > mail -s Test1 me@mydomain.com

but I don't think I've got it quite right with the piping !! (my first attempted is commented out).

(I've tried http://marc.info/?l=gnupg-devel&m=99470875105469&w=2 but can't get it to work)

Can anyone suggest what the correct syntax should be please?

Many tks,
Alex

P.S. I can pipe to Perl or PHP but I don't know either. If it's better to use Perl or PHP for this then I'm happy to try...but can I have some hints pls.

teknik 11-14-2008 01:51 PM

Where's the original mail message coming from? Assuming it is being piped to this program, try this:
Code:

#!/bin/bash

### the following line will send stdin to gpg, and send the output from gpg to mail
cat - | /usr/bin/gpg -ea -r me@mydomain.com | mail -s Test1 me@mydomain.com



All times are GMT -5. The time now is 05:46 AM.