Sponsored Content
Top Forums Shell Programming and Scripting sed command to parse Apache config file Post 302377354 by rdcwayx on Thursday 3rd of December 2009 10:10:44 PM
Old 12-03-2009
With your new output by below commands:

Code:
awk 'split($2,a,":") {$2=a[1]":"a[2]}1' urfile |awk 'split($2,a,"/") {$2=a[1]"//"a[3]}1' |sort -u
RewriteRule http://dev-individual.com [P,NC,L]
RewriteRule http://dev-obawls.com [P,NC,L]

But I can't make it in one command.Smilie

Or by nawk:

Code:
nawk 'split($2,a,":") {$2=a[1]":"a[2]} {print}' urfile |nawk 'split($2,a,"/") {$2=a[1]"//"a[3]} {print}' |sort -u
RewriteRule http://dev-individual.com [P,NC,L]
RewriteRule http://dev-obawls.com [P,NC,L]


Last edited by rdcwayx; 12-03-2009 at 11:16 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Apache Config

I need help doing two things in my Apache Config.... 1) Creating a Referer log where only domains other than my own (or a list I specify) are logged ...and... 2) I want to replace images loaded from my site, on other sites, it a standard RED "stolen" image. I currently have code in place... (2 Replies)
Discussion started by: l008com
2 Replies

2. Shell Programming and Scripting

How to parse config variables from external file to shell script

How do i use a config.txt to recursively pass a set of variables to a shell script eg my config.txt looks like this : path=c://dataset/set1 v1= a.bin v2= b.bin path=c://dataset/set2 v1= xy.bin v2= abc.bin .................. and so on . and my testscript : (2 Replies)
Discussion started by: pradsh
2 Replies

3. Shell Programming and Scripting

How to parse slash / in sed command..

Hi All, I am trying to replace paths with \ (as in NT) with / (as in Unix) in a script using sed. Following is the command I use: sed "s/e:\Kenny_test\csv_files/var/opt/ciw/data/outbound/g" EMEA4710.SQL > test the string to replace is e:\Kenny_test\csv_files the target string needs to... (3 Replies)
Discussion started by: Abhidey
3 Replies

4. Shell Programming and Scripting

awk/sed Command : Parse parameter file / send the lines to the ksh export command

Sorry for the duplicate thread this one is similar to the one in https://www.unix.com/shell-programming-scripting/88132-awk-sed-script-read-values-parameter-files.html#post302255121 Since there were no responses on the parent thread since it got resolved partially i thought to open the new... (4 Replies)
Discussion started by: rajan_san
4 Replies

5. Shell Programming and Scripting

awk/sed Command: To Parse Stament between 2 numbers

Hi, I need an awk command that would parse the below expression Input Format 1 'Stmt1 ............................'2 'Stmt2 ............................'3 'Stmt3 ............................'4 'Stmt4 ............................'5 'Stmt5 ............................'6 'Stmt6... (1 Reply)
Discussion started by: rajan_san
1 Replies

6. Shell Programming and Scripting

Parse config file and store the values in variables

Hi, I have a config file that has blank, commented lines. I need to escape commented lines, blank lines, parse the remaining lines and store them in variables or array. the config file contains the following lines. # config file # Define Oracle User ORA_USER=abcde ORA_PASS=xyzabc... (8 Replies)
Discussion started by: Lakshmi Chowdam
8 Replies

7. Shell Programming and Scripting

Parse config file data to script variable

I have a script with few pre defined variables. Also have a config file. Something like this. # config file # Define Oracle User MOD1_TAG=abcde MOD2_TAG=xyzabc MOD3_TAG=def I need to parse the config file and have each of the value copied to different variables. Please suggest what... (1 Reply)
Discussion started by: souryadipta
1 Replies

8. Red Hat

Apache virtual host config vs global config problem

Hi folks, I am trying to configure Apache webserver and also a virtual host inside this webserver. For Global server config: /var/www/html/index.html For virtual host config: /var/www/virtual/index.html Both client10 & www10 are pointing to 192.168.122.10 IP address. BUT, MY... (1 Reply)
Discussion started by: freebird8z
1 Replies

9. Shell Programming and Scripting

sed add line to config file

what is the sed command line to add a line to a config file config file name is "config" line to be added cpuid.7.edx = "----:00--:----:----:----:----:----:----" thanks (4 Replies)
Discussion started by: tdubb123
4 Replies

10. UNIX for Beginners Questions & Answers

Parse apache log file with three different time formats

Hi, I want to parse below file and Write a function to extract the logs between two given timestamp. Apache (Unix) Log Samples - MonitorWare The challenge here is there are three date and time format. First :- 07/Mar/2004:16:05:49 Second :- Sun Mar 7 16:02:00 2004 Third :- 29-Mar... (6 Replies)
Discussion started by: sahil_shine
6 Replies
ePerl(3pm)						User Contributed Perl Documentation						ePerl(3pm)

NAME
Apache::ePerl - Fast emulated Embedded Perl (ePerl) facility SYNOPSIS
# Apache's httpd.conf file # mandatory: activation of Apache::ePerl PerlModule Apache::ePerl <Directory /root/of/webmaster/area> <Files *.iphtml> Options +ExecCGI SetHandler perl-script PerlHandler Apache::ePerl </Files> </Directory> # optional: configuration of Apache::ePerl <Perl> $Apache::ePerl::Config->{'BeginDelimiter'} = '<?'; $Apache::ePerl::Config->{'EndDelimiter'} = '!>'; $Apache::ePerl::Config->{'CaseDelimiters'} = 0; $Apache::ePerl::Config->{'ConvertEntities'} = 1; </Perl> # optional: activation of Apache::Status for Apache::ePerl <Location /perl-status> Options +ExecCGI SetHandler perl-script PerlHandler Apache::Status </Location> DESCRIPTION
These packages provides a handler function for Apache/mod_perl which can be used to emulate the stand-alone Server-Side-Scripting-Language ePerl (see eperl(3) for more details) in a very fast way. This is not a real 100% replacement for nph-eperl because of reduced functionality under some special cases, principal runtime restrictions and speedup decisions. For instance this variant does not (and cannot) provide the SetUID feature of ePerl nor does it check for allowed filename extensions (speedup!), etc. Instead it uses further features like object caching which ePerl does not use. But the accepted bristled source file format is exactly the same as with the regular ePerl facility, because Apache::ePerl uses the Parse::ePerl package which provides the original ePerl parser and translator. So, any valid ePerl which works under nph-eperl can also be used under Apache::ePerl. The intent is to use this special variant of ePerl for scripts which are directly under control of the webmaster. In this situation no real security problems exists for him, because all risk is at his own hands. For the average user you should not use Apache::ePerl. Instead additionally install the regular stand-alone ePerl facility (nph-eperl) for those users. So, the advantage of Apache::ePerl against the regular nph-eperl is better performance and nothing else. Actually scripts executed under Apache::ePerl are at least twice as fast as under nph-eperl. The reason its not that ePerl itself is faster. The reason is the runtime in- core environment of Apache/mod_perl which does not have any forking overhead. Installation and Configuration First you have to install Apache::ePerl so that Apache/mod_perl can find it. This is usually done via configuring the ePerl distribution via the same Perl interpreter as was used when building Apache/mod_perl. Second, you have to add the following config snippet to Apache's httpd.conf file: PerlModule Apache::ePerl <Directory /root/of/webmaster/area> <Files *.iphtml> Options +ExecCGI SetHandler perl-script PerlHandler Apache::ePerl </Files> </Directory> This forces all files under the directory /root/of/webmaster/area/ with extension .iphtml to be processed by the Apache::ePerl::handler function which emulates the runtime behavior of the stand-alone "eperl" program (when run as a SSSL) up to 90%. If you're not paranoid about security (for instance driving a stand-alone webserver without user accounts) you can also just use PerlModule Apache::ePerl <Files *.iphtml> SetHandler perl-script PerlHandler Apache::ePerl </Files> which enables .iphtml files everywhere. Third, when you want to change the defaults of the ePerl parser, you also can add something like this to the end of the snippet above. <Perl> $Apache::ePerl::Config->{'BeginDelimiter'} = '<?'; $Apache::ePerl::Config->{'EndDelimiter'} = '!>'; $Apache::ePerl::Config->{'CaseDelimiters'} = 0; $Apache::ePerl::Config->{'ConvertEntities'} = 1; </Perl> Fourth, you can additionally enable the mod_perl runtime status which then automatically enables an Apache::ePerl status handler: <Location /perl-status> Options +ExecCGI SetHandler perl-script PerlHandler Apache::Status </Location> This enables the URL "/perl-status" in general and the URL "/perl-status?ePerl" in special. Use it to see how much scripts where run and how much are still cached. AUTHOR
Ralf S. Engelschall rse@engelschall.com www.engelschall.com HISTORY
Apache::ePerl was first implemented by Mark Imbriaco <mark@itribe.net> in December 1996 as a plain Perl module after he has seen the original ePerl from Ralf S. Engelschall. It implemented the ePerl idea, but was not compatible to the original ePerl. In May 1997 Hanno Mueller <hmueller@kabel.de> has taken over the maintenance from Mark I. and enhanced Apache::ePerl by adding caching for P-Code, adding the missing "chdir" stuff, etc. Nearly at the same time Ralf S. Engelschall was unhappy of the old Apache::ePerl from Mark I. and already started to write this version (the one you are current reading its POD). He has rewritten the complete module from scratch, but incorporated the P-Code caching idea and the Apache::Status usage from Hanno M.'s version. The big difference between this one and Mark I.'s or Hanno M.'s versions are that this version makes use of the new Parse::ePerl module which itself incorporates the original ePerl parser. So this version is more compliant to the original ePerl facility. SEE ALSO
Parse::ePerl(3) Web-References: Perl: perl(1), http://www.perl.com/ ePerl: eperl(1), http://www.engelschall.com/sw/eperl/ mod_perl: mod_perl(1), http://perl.apache.org/ Apache: httpd(7), http://www.apache.org/ perl v5.14.2 2012-04-07 ePerl(3pm)
All times are GMT -4. The time now is 12:43 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy