Please help me with Syntax problem- Parsing Mail Files

Please help me with Syntax problem- Parsing Mail Files

Post by joeh » Fri, 16 Jul 1999 04:00:00




> I have a problem on my UNIX mail server where some NT Clients/'MS
> Outlook' users cannot open their large file on the server; therefore i
> need to parse it, that is
> chop it up into individual files and then spoonfeed it to MS Outlook
> clients.
> I have a perl program to do this but Perl is not running on that server
> and i can't*around with it just at this moment;  would someone
> help me
> with my awk syntax below please?

> [a] #!/usr/bin/awk -f    (this i am using to pipe the file via stdout;
> but how can i capture the filename as a variable so that i can use it as
> a prefix?  I do not
>                                                want to use `awk -v
> awkVar="$shellVar" '...)

> [b] I have no problem matching the first line containing the String
> "from" and a "date"; am i correct in matching this line?
> /^[Ff]rom .* (Mon|Tue|Wed|Thu|Fri|Sat|Sun)/   (However, i would like to
> match this line only if it is followed by another match, the 'Received'
> line; then

> i can be fairly confident that this is a mail header.  Can anyone advise
> best way to match both lines?)

> [c] Once matching the lines i need to feed the output to  lines ideally
> prefixed with the original filename UNTIL reaching the next header; is
> there a way to
>        do this without repeating [b] above?

> If someone can help, many thanks
> Joe

> --

> access to a news server; thanks!
> Disclaimer: opinions expressed my own and not representative of my employers

--

access to a news server; thanks!
Disclaimer: opinions expressed my own and not representative of my employers
 
 
 

Please help me with Syntax problem- Parsing Mail Files

Post by Ken Pizzi » Sat, 17 Jul 1999 04:00:00



>> [a] #!/usr/bin/awk -f    (this i am using to pipe the file via stdout;
>> but how can i capture the filename as a variable so that i can use it as
>> a prefix?  I do not
>>                                                want to use `awk -v
>> awkVar="$shellVar" '...)

Does the FILENAME variable work for you?

Quote:>> [b] I have no problem matching the first line containing the String
>> "from" and a "date"; am i correct in matching this line?
>> /^[Ff]rom .* (Mon|Tue|Wed|Thu|Fri|Sat|Sun)/   (However, i would like to
>> match this line only if it is followed by another match, the 'Received'
>> line; then

>> i can be fairly confident that this is a mail header.  Can anyone advise
>> best way to match both lines?)

  { while (/^From .* (Mon|Tue|...etc...)/ {
      hold=$0
      getline
      if (/^Received/) {
        # We have a match!
        # (the "hold" variable contains the "From " line of interest)
        break
      }
    }
  }

Quote:>> [c] Once matching the lines i need to feed the output to  lines ideally
>> prefixed with the original filename UNTIL reaching the next header; is
>> there a way to
>>        do this without repeating [b] above?

Add an assignment like:
   prefix="whatever"
to the block of code where we matched [b].  Add a final awk command like:
   { print prefix, $0 }

All of the above assumes that you're not using "old awk", which lacks
some of the features used.  Also, these questions are better fitted
to comp.lang.awk .

                --Ken Pizzini

 
 
 

1. HELP -I accidently deleted a config file Please mail me the file.

Hi,

I accidently deleted some example fvwm-config files. The files where
included in the slackware 3.0 package (or the Infomagic CD rom set of
November).

Can somebody mail me these files. It would be very helpful for me!

Thank you in advance...

Joel Wijngaarde

PS.. Where can i find the icons on my disk which can be used by
GoodStuff button bar.

2. Screen dump from X in 16/24 bpp mode

3. ********* --- Ansi C Help Please --- *********** TIA - Parsing problem!!!!

4. Trantor 160 SCSI controller supported?

5. Parsing a saved mail file

6. LINUX PPP (PAP) and NT

7. Sendmail problems. Please please please please help!

8. Keyboard hangs at CDE login screen.

9. parse mail files:beginning Perl in UNIX environment

10. Parsing a Saved Mail File

11. parse and split mail files

12. Parse Mail files

13. PLEASE PLEASE HELP Major problem with my SCSI & Redhat 5.0 PLEASE Help