• Home
  • Popular Downloads
  • Contact Us
  • Submit

Softpile

Free Downloads

Main Navigation
  • Home
  • Windows
  • Mac OS X
  • Business
  • Desktop
  • Development
  • Education
  • Games
  • Internet
  • Multimedia
  • Utilities
Home » Linux » mod_sed

mod_sed

April 13, 2008
mod_sed is an Apache module that embeds a copy of the sed command.
Version: 0.1
License: The Apache License 2.0
Operating System: Linux
Homepage: search.cpan.org
Developed by: Dominic Mitchell
mod_sed is an Apache module that embeds a copy of the sed command. This means that you can automatically filter data without having to spawn a CGI process.

It probably doesn't have a lot of practical use, but I wrote it anyway. The main purpose was for me to learn how to write an apache module.

Requirements:

· Apache

BUILDING

To build, you should just be able to type in "make". I'm still working on the portability aspects of this module, so it might not run on your system yet. All patches appreciated.

You'll need apxs(8) to build this module, because at present, I don't understand Apache's static configuration (again, patches welcome). Either edit the Makefile to specify the location of it, or put it on the command line like this:

% make APXS=/usr/local/sbin/apxs

If your system doesn't have an fgetln(3) call (to test, see if "man fgetln" returns anything), you'll also have to uncomment a line in the Makefile.

To install, "make install" should copy the mod_sed.so to your data directory and put the correct lines in your httpd.conf to enable it.

TESTING

This is all the documentation you get until I write some more, I'm afraid.

You'll need: A directory or file that you want to run sed over inside Apache. In my case, this is "/usr/local/www/data/sed/". Copies of the files are in the "eg" subirectory. The httpd.conf fragment I used looked like this:

< Directory /usr/local/www/data/sed >
SetHandler sed-handler
SedExtendedRegex on
#SedProgram "s/foo/BAR/g"
SedProgram /usr/local/www/data/sedscr
SedPathMap /foo /usr/local/www/data/sedscr.foo
< /Directory >

You'll need to make sure that the directory you specify is visible from Apache. In fact, it's probably a good idea to do that /before/ installing this module...

The important bit to activate mod_sed is the "SetHandler" line. That enables all files under that directory to be passed through mod_sed.

The "SedExtendedRegex" line asks that sed use Enhanced Regexes instead of basic ones. If you don't know what that means, always include this line. For more details on the differences between basic regexes and extended regexes see re_format(7).

The "SedProgram" keyword can specify either a whole sed program (like you would give on the command line with -e) or a pathname to a file containing a sed program (this is generally the preferred option). To determine between the two, mod_sed will attempt to see if a file by that name exists, otherwise it'll try and compile it as a program.

The last command, "SedPathMap" takes two arguments: a PATH_INFO and another SedProgram argument. What it means is that when somebody requests a file:

http://my.server/sed/index.html/foo

The sed program in /usr/local/www/data/sedscr.foo will get run instead of the default in SedProgram. This can be very handy for serving up alternative versions of files.
apache apache module embed sed embedded filter data sed
Free Download 23K
0
  • Share on:

mod_sed User Reviews

Sponsored

Categories

  • Linux

Related Downloads

django-listings
A classifieds app for Django
The Powered Access Bible
A tool to allow free and effective access to the Bible.
SRESI
SRESI is a smart bookmarks manager: from a list of tagged bookmarks.
Booh
A static Web-album generator
WebCore
Yet Another Python Web Framework
Copyright © 1999-2017 Softpile Free Downloads
  • Contact Us
  • Submit
  • Privacy Policy
  • Disclaimer
  • Terms of Use