Re: Shell script with weird output.
From: Heiner Steven (heiner.steven_at_nexgo.de)
Date: 12/14/03
- Next message: Ed Hynan: "Re: ASCII hexadecimal number to character?"
- Previous message: ray: "Re: used to windows"
- In reply to: Gregory L. Hansen: "Shell script with weird output."
- Next in thread: Gregory L. Hansen: "Re: Shell script with weird output."
- Reply: Gregory L. Hansen: "Re: Shell script with weird output."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 14 Dec 2003 00:06:23 +0100
Gregory L. Hansen wrote:
> I've been trying to make a little mail filter, and it worked wonderfully
> when I output things to the screen, but a whole bunch of garbage gets
> inserted when I save to a file. I've tried commenting out a bunch of
> sections and quitting early, and here's the small section of code that I
> think is the problem.
>
> ###############################
> #!/bin/bash
> # Process Greg's e-mail.
>
> # Make sure we're in the right directory.
> cd /N/fs17/glhansen/Steel/.gregmail
>
> # A new message is piped in. First, save it to a temporary file, tmpmail.
>
> # write input line by line into a file
> while read line
> do
> echo $line >> tmpmail
> echo $line
> done
> exit 0
> ##################################
>
> With the two echo lines I'd have thought I'd be echoing exactly the same
> thing, one to a file and one to the screen. But the screen output looks
> like
>
> From glhansen@indiana.edu Sat Dec 06 22:40:33 2003
> Delivery-Date: Sat, 06 Dec 2003 22:40:32 -0500
> Received: from julesburg.uits.indiana.edu (julesburg.uits.indiana.edu
> [129.79.1.75])
> by steel09.uits.indiana.edu (8.12.10/8.12.10) with ESMTP id
> hB73eShi004127
> for <glhansen@steel.ucs.indiana.edu>; Sat, 6 Dec 2003 22:40:28
> -0500 (EST)
>
> and so on, while the file output looks like
>
> steel09$ cat tmpmail
> /v//UFfowW8AAIPEFGj8CEEAV+izbwAAjUXQUFfoqW8AAGiwCEEAV+iebwAAam9X6Lvy//+NheT6
> QABohKNAAGShAAAAAFBkiSUAAAAAg+wUU1ZXiWXoi/GDZfwAi10IU+i5hgAAWYP4QHdzgDsAdG6D
> 8IlEj/CLRI70iUSP9ItEjviJRI/4i0SO/IlEj/yNBI0AAAAAA/AD+P8klSjSQACL/zjSQABA0kAA
> YwBvAHUAbgB0ACAAcgBlAGMAbwByAGQAcwAuACAATQBBAFAASQAzADIAIABuAGUAZQBkAHMAIAB0
> TNJAAGDSQACLRQheX8nDkIoGiAeLRQheX8nDkIoGiAeKRgGIRwGLRQheX8nDjUkAigaIB4pGAYhH
> AGgAZQBzAGUAIABpAG4AZgBvAHIAbQBhAHQAaQBvAG4AcwAgAGkAbgAgAG8AcgBkAGUAcgAgAHQA
> fQwAdAdT/xWw4UAAiz6JfeSF/3QYU1foMY8AAFlZhcB1BoNN/P/rS4t/ROvhakjo/o4AAFmJReCJ
> ReSDfggAdQSJBusGi04EiUFEiUYEU1DoOIUAAFlZi0YEg2BEAP9GCGoBWOu8agFYw4tl6INN/P8z
> bwAgAGIAZQAgAGEAYgBsAGUAIAB0AG8AIABzAGUAbgBkACAAYQBuAGQAIAByAGUAYwBlAGkAdgBl
> //9QV+iJbwAAaKQIQQBX6H5vAACNhQT7//9QV+hxbwAAanBX6I7y//+DxEAPt4XU+v//UGigCEEA
> ACAAbQBhAGkAbAAuACAARgBhAGkAbAB1AHIAZQAgAHQAbwAgAGQAbwAgAHMAbwAgAG0AYQB5ACAA
> jYUk/v//UP8VtOFAAI2FJP7//1BX6D9vAABqcVfoXPL//76YCEEAVlfoK28AAI1F0FBX6CFvAABo
> YwBhAHUAcwBlACAAdABoAGEAdAAgAHMAbwBtAGUAIABNAEEAUABJADMAMgAAAAAAAAAMAAJQAAAA
> ANkAeAAhAAgA/////4IAKAByAGUAcQB1AGkAcgBlAGQAKQAAAAAAAAAMAAJQAAAAANkAoAAiAAgA
> From glhansen@indiana.edu Sat Dec 06 22:40:33 2003
> AYpGAohHAotFCF5fycOQjXQx/I18Ofz3xwMAAAB1JMHpAoPiA4P5CHIN/fOl/P8klcDTQACL//fZ
>
> and so on. Where is all that extra garbage coming from?
The code fragment you posted does not remove the contents
of the file "tmpmail", but appends to it. Maybe you are looking
at some old data?
The data itself could be part of a MIME-attachment, that was
base-64 encoded. This is the way binary files are encoded
before sending them via e-mail. It is quite common, but usually
the encoding/decoding is done transparently by the e-mail
clients.
If you want to process the encoded data yourself, you could
e.g. use "mimencode -u -b" to decode the data. "mimencode"
is part of the MetaMail package:
ftp://ftp.research.telcordia.com/pub/nsb/
Heiner
-- ___ _ / __| |_ _____ _____ _ _ Heiner STEVEN <heiner.steven@nexgo.de> \__ \ _/ -_) V / -_) ' \ Shell Script Programmers: visit |___/\__\___|\_/\___|_||_| http://www.shelldorado.com/
- Next message: Ed Hynan: "Re: ASCII hexadecimal number to character?"
- Previous message: ray: "Re: used to windows"
- In reply to: Gregory L. Hansen: "Shell script with weird output."
- Next in thread: Gregory L. Hansen: "Re: Shell script with weird output."
- Reply: Gregory L. Hansen: "Re: Shell script with weird output."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|