 |
 |
Need help with a sed command
|
 |
|
 |
|
Mac Elite
Join Date: Aug 2001
Location: Madison, WI
Status:
Offline
|
|
My office's new voicemail system will forward .wav attachments to your email, if requested. The small problem is that they come across with a content boundary of
Content-Type: application/octet-stream; name="VM.WAV"
While this works, it shows an attachment that wants to be opened in iTunes.
When the same message is forwarded, it comes across as
Content-Type: audio/x-wav
These forwards show a quicktime controller in mail.app- much more desireable than sticking it all in iTunes. So- I should be able to stick a sed command in .procmailrc to rewrite these files with the more desireable Content-Type, and get attachments that play in mail.app. I'm able to do a simple sed that turns night into day:
sed -e s/night/day
But can't get a more complicated one to work. I think the problem is that the content I'm finding and replacing all contain the / in it, which is also sed's delimiter. I've tried delimiting it as \/ and `\/' per online references I've found, but it's never worked out. Procmail only logs "error while writing to "<my sed statement here>"
So to summarize, the intent is to have procmail call sed, who looks for a line like
Content-Type: application/octet-stream; name="VM.WAV"
and replaces it with
Content-Type: audio/x-wav
Can anyone tell me what that should look like? I've seen 2 dozen things it shouldn't look like today.....
|
|
OS X: Where software installation doesn't require wizards with shields.
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Aug 2001
Location: Madison, WI
Status:
Offline
|
|
The answer is that the sed I was using didn't do expressions like anything else I'd ever seen. It wanted every form of punctuation escaped. Most interesting was to get a literal /, it demands double escapes: \\/ .
|
|
OS X: Where software installation doesn't require wizards with shields.
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2001
Location: Chico, CA and Carlsbad, CA.
Status:
Offline
|
|
Originally posted by C.J. Moof:
The answer is that the sed I was using didn't do expressions like anything else I'd ever seen. It wanted every form of punctuation escaped. Most interesting was to get a literal /, it demands double escapes: \\/ .
Did you end up using a new version of sed? GNU maybe?
|
"In Nomine Patris, Et Fili, Et Spiritus Sancti"
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Oct 2000
Location: Seattle
Status:
Offline
|
|
sed uses 'basic regular expressions' which is a little different that grep or perl. If you look at the find panel in subethaedit it gives you a choice of 7 different flavors. I learned reg ex with bbedit and it drove me nuts when I later tried to use php's ereg_replace() or grep on the command line.
If I remember right sed can use other delimiters.
a quick grab from the man page that may not be helpful:
s/regular expression/replacement/flags
Substitute the replacement string for instances of the regular expression in the pattern space. Any character other than backslash or newline can be used instead of a slash to delimit the RE and the replacement.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Aug 2001
Location: Madison, WI
Status:
Offline
|
|
'Basic regular expressions' vs grep/perl regex? I never realized there was more than one kind. Maybe I wouldn't have had so much trouble with this if I knew it might be this kind of regex, or that kind of regex.
I ended up using the same sed that came with the system I was working on (a Linux flavor, not OS X btw), I just finally deciphered it's rules by trial and error- digesting little bits and hacking around until I figured out what worked. For the record:
Code:
| sed -e s/Content\-Type\:\ application\\/octet\-stream\;\ name\=\"VM\.WAV\"/Content\-Type\:\ audio\\/x\-wav\;/
|
|
OS X: Where software installation doesn't require wizards with shields.
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Aug 2001
Location: Madison, WI
Status:
Offline
|
|
Ha! The forum's code tag doesn't turn off smilies? That's comical.
|
|
OS X: Where software installation doesn't require wizards with shields.
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Nov 2004
Location: Stockholm, Sweden
Status:
Offline
|
|
Originally posted by C.J. Moof:
Ha! The forum's code tag doesn't turn off smilies? That's comical.
it does if you check the Disable Smilies in This Post option.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Aug 2001
Location: Madison, WI
Status:
Offline
|
|
Sure, but when I'm already designating content as code, "no smilies here" ought to be implied.
|
|
OS X: Where software installation doesn't require wizards with shields.
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Oct 2000
Location: Seattle
Status:
Offline
|
|
I think the lesson here is "computers are hard" 
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Mar 2004
Status:
Offline
|
|
Originally posted by Gavin:
I think the lesson here is "computers are hard"
regex or smilies?
|
|
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Jun 2000
Status:
Offline
|
|
It's so AOL users won't be afraid of the code tag.
Code:
#include <aol.h>
int LOL!!11(){
:)
}
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|