TCLUG Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How can I ...(procmail and stuff)



>> Received: from hearingsociety.org (root@sf-usr2-49-241.dialup.slip.net)  

That should be with sed :
address=`echo "Received: ........" | sed "s:^[^\@]*\@\([^)]*\)):\1:" `

` : is the backquote it will execute the command enclosed.
The "sed" grammar reads :
Substitute: Start of line "^" followed by a character not a "@"  '[^\@]' 
                    and more of not a "@" '*' followed by one "@". 
                    Then start remembering  whatever comes next '\(' 
                    and store it in '\1'.  
                    Look for as many characters that are not a closing
parenthesis '[^)]*'. 
                    Stop remembering '\)' 
                    then there should be a closing parenthesis ')'.
                  : Substitute all that with whatever you remembered '\1'
                  : End of it all !

Should put the address you need into the variable "address".
You can then do a 
telnet $address

To get all this done from procmail, I guess you need a .procmailrc with the
following:

# Telnet to the machine on the header.
:0 hH
 * ^Received: from hearingsociety.org (root@\/.*
    | (xterm -e telnet `echo $MATCH | sed "s:)::"` &)

The * ^Received.... matches the string that you are looking for. The "\/" is a
back slash
followed by a forward slash which breaks the input string into 2 parts and
puts the second part into the MATCH variable.

Then you run xterm with telnet in it but we still have to remove the last ")"
in the string since MATCH has everything after the "sf-
usr2-49-241.dialup.slip.net" which is what the echo ... | sed do.  Again the
quotes are backquotes. 

If this will work I do not know. I am not familar with procmail and I guessed
my way through the man pages hoping to learn something new in the process of
answering your question since I am bored right now and cannot seem to be able
to go to sleep.

Let me know if this does work though..

--
sandipan