Sponsored Content
Full Discussion: grep for special charecters
Top Forums UNIX for Dummies Questions & Answers grep for special charecters Post 302545923 by shifahim on Wednesday 10th of August 2011 03:37:11 AM
Old 08-10-2011
Error

Quote:
Originally Posted by Peasant
Use nawk on Solaris.

I'm not sure i'm getting this, please check if this works for your using nawk.
Code:
$ cat inp
er [01/Aug/2011:00:00:55 -0400] "POST  /servlet/lorms/lorms_modify_user HTTP/1.1" 200 133694
16.81.18.145 -  - [01/Aug/2011:00:01:25 -0400] "GET  /eg/Hello.jsp?name=eg&name1=monitoring&user=eg&password

bla bla bla

162.11.18.145 - - [02/Aug/2011:00:00:29 -0400] "GET  /eg/Hello.jsp?name=eg&name1=monitoring&user=eg&password=48&host=169.81.&port=3333&server=myserver  HTTP/1.1" 200 170

bla bla bla ....
$ awk '!/0[12]\/Aug/ { print } '  inp

bla bla bla


bla bla bla ....

Hope this helps, if not, perhaps someone else will jump in.

Regards
Peasant.
Why does it print the second bla bla bla ?

This is my desired output for the above:

Code:
[01/Aug/2011:00:00:55 -0400] "POST  /servlet/lorms/lorms_modify_user  HTTP/1.1" 200 133694
16.81.18.145 -  - [01/Aug/2011:00:01:25 -0400] "GET   /eg/Hello.jsp?name=eg&name1=monitoring&user=eg&password

bla bla bla

162.11.18.145 - - [02/Aug/2011:00:00:29 -0400] "GET   /eg/Hello.jsp?name=eg&name1=monitoring&user=eg&password=48&host=169.81.&port=3333&server=myserver   HTTP/1.1" 200 170

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep with Special Characters

I need to sort a file, the sort is not a alphabetical sort, it's based on a predefined order which is read from a file called fSortOrder. The format of the fSortOrder file is : STARTPATH" .... .... The file that needs to be sorted is called tmpUnsorted and contains data in the format : ... (6 Replies)
Discussion started by: Vashj
6 Replies

2. UNIX Desktop Questions & Answers

grep with special characters

Hi there I need to grep for a detail from a file. The pattern to search for involves escape sequences in it. This causes for the problem. grep "P\_SOME\_STRING\_SEARCH" filename Note, I have line like below in the file and expect it to grep. select * from my_system_param ... (3 Replies)
Discussion started by: guruparan18
3 Replies

3. Shell Programming and Scripting

Grep not working - special characters??

I have a file that I am processing with a while loop from, in come cases the grep/sed command (strings record | grep “errorDetail” | sed 's&*errorDetail\(.*)\(/errorDetail\).*&\1&') works and produces the data I am after and in some it does not. I have inspected the data within the failing... (3 Replies)
Discussion started by: gugs
3 Replies

4. UNIX for Advanced & Expert Users

grep in special character

All, I am trying to grep "-----" from a test when i use this i am getting the below error. What is the reason for this ?????... How can i over come this ##) echo "----------------- test_sys_job -----------------" | grep "-----------------" grep: illegal option -- - grep: illegal... (6 Replies)
Discussion started by: arunkumar_mca
6 Replies

5. UNIX for Dummies Questions & Answers

Using GREP for special characters

Hi folks I am issuing the following command: grep "" * Looking for the characters \/:*?"<>|#+%& within all files in a directory, but the command fails being unhappy with pipe: ksh: 0403-057 Syntax error: `|' is not expected. How do I force the command to take the pipe | ? I guess... (2 Replies)
Discussion started by: daveaasmith
2 Replies

6. Shell Programming and Scripting

grep for a special range

hi, i search a command to get follow solution: file: 21082009mueller01testtest 22082009mueller02testtest 23082009mueller03testtest 24082009mueller02testtest 25082009mueller03testtest Solution: I search all lines with "mueller02" at the range 8 to 17 It is possible with greb... (5 Replies)
Discussion started by: Timmää
5 Replies

7. Shell Programming and Scripting

Grep with special Characters

Need Help For GREP I have a file say g1.txt and content of file is below REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" /v NoDrives /t REG_DWORD /d 4 /f , REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" /v NoClose /t REG_DWORD /d 1 /f ,... (4 Replies)
Discussion started by: jalpasoni
4 Replies

8. Shell Programming and Scripting

grep lines having special characters

Hi, I have a file which has numerous lines and some of the lines having special characters in it. i want to grep the lines which are having special characters. say, one line looks like - %*()$#@"", | acbd antoher line looks like ***##^%! | efcg so these kind of lines are present... (5 Replies)
Discussion started by: rbalaj16
5 Replies

9. Shell Programming and Scripting

Grep -F for special character

a='CASH$$A' /usr/xpg4/bin/grep -F "$a" *.txt It is not able to grep CASH$$A string as it contains special character $$. I also tried with /usr/xpg4/bin/grep -F '$a' *.txt but still not working. I have to assign CASH$$A to a variable and serach that variable..i dont want to search the... (8 Replies)
Discussion started by: millan
8 Replies

10. Shell Programming and Scripting

Removing special ^M charecters

Hi, This code works for me for file in $(find /path/to/dir -type f); do tr -d '\r' <$file >temp.$$ && mv temp.$$ $file done However, i want this code to skip all .class files. Can you help me with the modified code. (2 Replies)
Discussion started by: mohtashims
2 Replies
AnyEvent::HTTPD(3pm)					User Contributed Perl Documentation				      AnyEvent::HTTPD(3pm)

NAME
AnyEvent::HTTPD - A simple lightweight event based web (application) server VERSION
Version 0.93 SYNOPSIS
use AnyEvent::HTTPD; my $httpd = AnyEvent::HTTPD->new (port => 9090); $httpd->reg_cb ( '/' => sub { my ($httpd, $req) = @_; $req->respond ({ content => ['text/html', "<html><body><h1>Hello World!</h1>" . "<a href="/test">another test page</a>" . "</body></html>" ]}); }, '/test' => sub { my ($httpd, $req) = @_; $req->respond ({ content => ['text/html', "<html><body><h1>Test page</h1>" . "<a href="/">Back to the main page</a>" . "</body></html>" ]}); }, ); $httpd->run; # making a AnyEvent condition variable would also work DESCRIPTION
This module provides a simple HTTPD for serving simple web application interfaces. It's completly event based and independend from any event loop by using the AnyEvent module. It's HTTP implementation is a bit hacky, so before using this module make sure it works for you and the expected deployment. Feel free to improve the HTTP support and send in patches! The documentation is currently only the source code, but next versions of this module will be better documented hopefully. See also the "samples/" directory in the AnyEvent::HTTPD distribution for basic starting points. FEATURES
o support for GET and POST requests. o support for HTTP 1.0 keep-alive. o processing of "x-www-form-urlencoded" and "multipart/form-data" ("multipart/mixed") encoded form parameters. o support for streaming responses. o with version 0.8 no more dependend on LWP for HTTP::Date. o (limited) support for SSL METHODS
The AnyEvent::HTTPD class inherits directly from AnyEvent::HTTPD::HTTPServer which inherits the event callback interface from Object::Event. Event callbacks can be registered via the Object::Event API (see the documentation of Object::Event for details). For a list of available events see below in the EVENTS section. new (%args) This is the constructor for a AnyEvent::HTTPD object. The %args hash may contain one of these key/value pairs: host => $host The TCP address of the HTTP server will listen on. Usually 0.0.0.0 (the default), for a public server, or 127.0.0.1 for a local server. port => $port The TCP port the HTTP server will listen on. If undefined some free port will be used. You can get it via the "port" method. ssl => $tls_ctx If this option is given the server will listen for a SSL/TLS connection on the configured port. As $tls_ctx you can pass anything that you can pass as "tls_ctx" to an AnyEvent::Handle object. Example: my $httpd = AnyEvent::HTTPD->new ( port => 443, ssl => { cert_file => "/path/to/my/server_cert_and_key.pem" } ); Or: my $httpd = AnyEvent::HTTPD->new ( port => 443, ssl => AnyEvent::TLS->new (...), ); request_timeout => $seconds This will set the request timeout for connections. The default value is 60 seconds. backlog => $int The backlog argument defines the maximum length the queue of pending connections may grow to. The real maximum queue length will be 1.5 times more than the value specified in the backlog argument. See also "man 2 listen". By default will be set by AnyEvent::Socket"::tcp_server" to 128. connection_class => $class This is a special parameter that you can use to pass your own connection class to AnyEvent::HTTPD::HTTPServer. This is only of interest to you if you plan to subclass AnyEvent::HTTPD::HTTPConnection. request_class => $class This is a special parameter that you can use to pass your own request class to AnyEvent::HTTPD. This is only of interest to you if you plan to subclass AnyEvent::HTTPD::Request. allowed_methods => $arrayref This parameter sets the allowed HTTP methods for requests, defaulting to GET, HEAD and POST. Each request received is matched against this list, and a '501 not implemented' is returned if no match is found. Requests using disallowed handlers will never trigger callbacks. port Returns the port number this server is bound to. host Returns the host/ip this server is bound to. allowed_methods Returns an arrayref of allowed HTTP methods, possibly as set by the allowed_methods argument to the constructor. stop_request When the server walks the request URI path upwards you can stop the walk by calling this method. You can even stop further handling after the "request" event. Example: $httpd->reg_cb ( '/test' => sub { my ($httpd, $req) = @_; # ... $httpd->stop_request; # will prevent that the callback below is called }, '' => sub { # this one wont be called by a request to '/test' my ($httpd, $req) = @_; # ... } ); run This method is a simplification of the "AnyEvent" condition variable idiom. You can use it instead of writing: my $cvar = AnyEvent->condvar; $cvar->wait; stop This will stop the HTTP server and return from the "run" method if you started the server via that method! EVENTS
Every request goes to a specific URL. After a (GET or POST) request is received the URL's path segments are walked down and for each segment a event is generated. An example: If the URL '/test/bla.jpg' is requestes following events will be generated: '/test/bla.jpg' - the event for the last segment '/test' - the event for the 'test' segment '' - the root event of each request To actually handle any request you just have to register a callback for the event name with the empty string. To handle all requests in the '/test' directory you have to register a callback for the event with the name '/test'. Here is an example how to register an event for the example URL above: $httpd->reg_cb ( '/test/bla.jpg' => sub { my ($httpd, $req) = @_; $req->respond ([200, 'ok', { 'Content-Type' => 'text/html' }, '<h1>Test</h1>' }]); } ); See also "stop_request" about stopping the walk of the path segments. The first argument to such a callback is always the AnyEvent::HTTPD object itself. The second argument ($req) is the AnyEvent::HTTPD::Request object for this request. It can be used to get the (possible) form parameters for this request or the transmitted content and respond to the request. Along with the above mentioned events these events are also provided: request => $req Every request also emits the "request" event, with the same arguments and semantics as the above mentioned path request events. You can use this to implement your own request multiplexing. You can use "stop_request" to stop any further processing of the request as the "request" event is the first thing that is executed for an incoming request. An example of one of many possible uses: $httpd->reg_cb ( request => sub { my ($httpd, $req) = @_; my $url = $req->url; if ($url->path =~ //images/img_(d+).jpg$/) { handle_image_request ($req, $1); # your task :) # stop the request from emitting further events # so that the '/images/img_001.jpg' and the # '/images' and '' events are NOT emitted: $httpd->stop_request; } } ); client_connected => $host, $port client_disconnected => $host, $port These events are emitted whenever a client coming from "$host:$port" connects to your server or is disconnected from it. CACHING
Any response from the HTTP server will have "Cache-Control" set to "max-age=0" and also the "Expires" header set to the "Date" header. Meaning: Caching is disabled. You can of course set those headers yourself in the response, or remove them by setting them to undef, but keep in mind that the default for those headers are like mentioned above. If you need more support here you can send me a mail or even better: a patch :) AUTHOR
Robin Redeker, "<elmex at ta-sa.org>" BUGS
Please report any bugs or feature requests to "bug-bs-httpd at rt.cpan.org", or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=AnyEvent-HTTPD <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=AnyEvent-HTTPD>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. SUPPORT
You can find documentation for this module with the perldoc command. perldoc AnyEvent::HTTPD You can also look for information at: o Git repository http://git.ta-sa.org/AnyEvent-HTTPD.git <http://git.ta-sa.org/AnyEvent-HTTPD.git> o RT: CPAN's request tracker http://rt.cpan.org/NoAuth/Bugs.html?Dist=AnyEvent-HTTPD <http://rt.cpan.org/NoAuth/Bugs.html?Dist=AnyEvent-HTTPD> o AnnoCPAN: Annotated CPAN documentation http://annocpan.org/dist/AnyEvent-HTTPD <http://annocpan.org/dist/AnyEvent-HTTPD> o CPAN Ratings http://cpanratings.perl.org/d/AnyEvent-HTTPD <http://cpanratings.perl.org/d/AnyEvent-HTTPD> o Search CPAN http://search.cpan.org/dist/AnyEvent-HTTPD <http://search.cpan.org/dist/AnyEvent-HTTPD> ACKNOWLEDGEMENTS
Andrey Smirnov - for keep-alive patches. Pedro Melo - for valuable input in general and patches. Nicholas Harteau - patch for ';' pair separator support, patch for allowed_methods support Chris Kastorff - patch for making default headers removable and more fault tolerant w.r.t. case. Mons Anderson - Optimizing the regexes in L<AnyEvent::HTTPD::HTTPConnection> and adding the C<backlog> option to L<AnyEvent::HTTPD>. COPYRIGHT &; LICENSE Copyright 2008-2011 Robin Redeker, all rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2011-08-04 AnyEvent::HTTPD(3pm)
All times are GMT -4. The time now is 05:29 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy