Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Changing array of data by sed Post 303044843 by teefa14 on Thursday 5th of March 2020 03:38:55 AM
Old 03-05-2020
Thanks alot
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Changing text with sed?

Hi everyone, Having trouble with sed. I searched the board and found some stuff, but still unclear. I have a file named "userfile" which stores the users info in this form: email:username:password: I want the user to be able to change their password. i tried with sed s/oldpass/newpass/g... (2 Replies)
Discussion started by: primal
2 Replies

2. Shell Programming and Scripting

Changing Special Characters Using Sed

Hi. Does anyone know how to use the sed command to change the special border characters on this .per file. I have to edit about 80 .per files. I need a sed script to change the below 3 and A characters. ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Test Islands, Office of Public Health -- WIC... (4 Replies)
Discussion started by: cstovall
4 Replies

3. UNIX for Dummies Questions & Answers

Changing the order using sed

I have a text "abc def ghi" and I want to get it as "def abc ghi" I am using this echo "abc def ghi" | sed 's/\(*\)\(*\)/\2\1/' But I am not able to get the output, could anyone help me. Thanks (9 Replies)
Discussion started by: venu_nbk
9 Replies

4. Shell Programming and Scripting

sed and changing the file itself

hello I have this: sed -e "s/install_location=....../g" -e "s/hostname=....../g" -e "s/server_name=....../y" input.txt it will display on the screen what have changed. however I want to change file input.txt. Any idea other than doing redirection (>) thx (2 Replies)
Discussion started by: melanie_pfefer
2 Replies

5. UNIX for Dummies Questions & Answers

changing data into matrix form

Hi, I have a file whose structure is like this 7 7 1 2 3 4 5 1 3 4 8 6 1 4 5 6 0 2 6 8 3 8 2 5 7 8 0 5 7 9 4 1 3 8 0 2 2 3 5 6 8 basically first two row tell the number of rows and column but the data following them are not arranged in that format. now i want to create another... (1 Reply)
Discussion started by: g0600014
1 Replies

6. Shell Programming and Scripting

changing c comments to c++ style with sed

Hi everyone, I've got a problem with converting C comments ( /* */ ) into C++ style ( // ) in some source file with sed. So far I've dealt with comments on one line, but I don't know how to convert when it is over multiple lines ... So I already have something like this: comments.sed ... (8 Replies)
Discussion started by: kolage
8 Replies

7. UNIX for Dummies Questions & Answers

Changing Text with sed or awk

I'm changing some html code on multiple web pages and I need to match particular phrases but keep some text within each phrase. E.G. I need to change this line: <DIV id="heading">Description:</DIV> into <span class="hlred">Description:</span><br /> The text "Description:" may... (2 Replies)
Discussion started by: hal8000
2 Replies

8. Shell Programming and Scripting

sed/awk changing values

Can somebody help me out and provide me with a SED or AWK solution that converts TO_DATE CLAUSE -> TIMESTAMP I need to keep the PARTION value (HISTORY_20110417) and DATE/TIME value (2011-04-18 00:00:00) the same for every line PARTITION HISTORY_20110417 VALUES LESS THAN (TO_DATE('... (3 Replies)
Discussion started by: BeefStu
3 Replies

9. UNIX for Dummies Questions & Answers

Changing data format from column into array

I have a file containing numbers in a column like: 10.5 16.3 15.7 2.3 46.8 3.3 . . . and I was wondering if there was a way to make it show up in an array form like: 10.5 2.3 16.3 46.8 15.7 3.3 Let's say I want to make a new column every 100 values. How can I do... (8 Replies)
Discussion started by: ShiGua
8 Replies

10. Shell Programming and Scripting

Changing time-stamp with sed

Hi ! I try to change a time-stamp hh:mm:ss allways to full ten-minutes. example: 12:51:03 to 12:50:03 sed 's/::/:{0-5}0:/g' file.txt but it will not work propperly, because the minute-decade will be replaced with the bracket-term {0-5}. Can someone please give me a hint? Thanks in... (6 Replies)
Discussion started by: IMPe
6 Replies
POE::Component::Server::HTTP(3pm)			User Contributed Perl Documentation			 POE::Component::Server::HTTP(3pm)

NAME
POE::Component::Server::HTTP - Foundation of a POE HTTP Daemon SYNOPSIS
use POE::Component::Server::HTTP; use HTTP::Status; my $aliases = POE::Component::Server::HTTP->new( Port => 8000, ContentHandler => { '/' => &handler1, '/dir/' => sub { ... }, '/file' => sub { ... } }, Headers => { Server => 'My Server' }, ); sub handler { my ($request, $response) = @_; $response->code(RC_OK); $response->content("Hi, you fetched ". $request->uri); return RC_OK; } POE::Kernel->call($aliases->{httpd}, "shutdown"); # next line isn't really needed POE::Kernel->call($aliases->{tcp}, "shutdown"); DESCRIPTION
POE::Component::Server::HTTP (PoCo::HTTPD) is a framework for building custom HTTP servers based on POE. It is loosely modeled on the ideas of apache and the mod_perl/Apache module. It is built alot on work done by Gisle Aas on HTTP::* modules and the URI module which are subclassed. PoCo::HTTPD lets you register different handler, stacked by directory that will be run during the cause of the request. Handlers Handlers are put on a stack in fifo order. The path /foo/bar/baz/honk.txt will first push the handlers of / then of /foo/ then of /foo/bar/, then of /foo/bar/baz/, and lastly /foo/bar/baz/honk.txt. Pay attention to directories! A request for /honk will not match /honk/ as you are used to with apache. If you want /honk to act like a directory, you should have a handler for /honk which redirects to /honk/. However, there can be only one ContentHandler and if any handler installs a ContentHandler that will override the old ContentHandler. If no handler installs a ContentHandler it will find the closest one directory wise and use it. There is also a special StreamHandler which is a coderef that gets invoked if you have turned on streaming by doing $response->streaming(1); Handlers take the $request and $response objects as arguments. RC_OK Everything is ok, please continue processing. RC_DENY If it is a TransHandler, stop translation handling and carry on with a PreHandler, if it is a PostHandler do nothing, else return denied to the client. RC_WAIT This is a special handler that suspends the execution of the handlers. They will be suspended until $response->continue() is called, this is usefull if you want to do a long request and not blocck. The following handlers are available. TransHandler TransHandlers are run before the URI has been resolved, giving them a chance to change the URI. They can therefore not be registred per directory. new(TransHandler => [ sub {return RC_OK} ]); A TransHandler can stop the dispatching of TransHandlers and jump to the next handler type by specifing RC_DENY; PreHandler PreHandlers are stacked by directory and run after TransHandler but before the ContentHandler. They can change ContentHandler (but beware, other PreHandlers might also change it) and push on PostHandlers. new(PreHandler => { '/' => [sub {}], '/foo/' => [&foo]}); ContentHandler The handler that is supposed to give the content. When this handler returns it will send the response object to the client. It will automaticly add Content-Length and Date if these are not set. If the response is streaming it will make sure the correct headers are set. It will also expand any cookies which have been pushed onto the response object. new(ContentHandler => { '/' => sub {}, '/foo/' => &foo}); ErrorHandler This handler is called when there is a read or write error on the socket. This is most likely caused by the remote side closing the connection. $resquest->is_error and $response->is_error will return true. Note that "PostHanlder" will still called, but "TransHandler" and "PreHandler" won't be. It is a map to coderefs just like ContentHandler is. PostHandler These handlers are run after the socket has been flushed. new(PostHandler => { '/' => [sub {}], '/foo/' => [&foo]}); StreamHandler If you turn on streaming in any other handler, the request is placed in streaming mode. This handler is called, with the usual parameters, when streaming mode is first entered, and subsequently when each block of data is flushed to the client. Streaming mode is turned on via the $response object: $response->streaming(1); You deactivate streaming mode with the same object: $response->close; Content is also sent to the client via the $response object: $response->send($somedata); The output filter is set to POE::Filter::Stream, which passes the data through unchanged. If you are doing a multipart/mixed response, you will have to set up your own headers. Example: sub new { ..... POE::Component::Filter::HTTP->new( ContentHandler => { '/someurl' => sub { $self->someurl(@_) }, StreamHandler => sub { $self->stream(@_), ); } sub someurl { my($self, $resquest, $response)=@_; $self->{todo} = [ .... ]; $response->streaming(1); $response->code(RC_OK); # you must set up your response header $response->content_type(...); return RC_OK; } sub stream { my($self, $resquest, $response)=@_; if( @{$self->{todo}} ) { $response->send(shift @{$self->{todo}}); } else { $response->close; } } Another example can be found in t/30_stream.t. The parts dealing with multipart/mixed are well documented and at the end of the file. NOTE: Changes in streaming mode are only verified when StreamHandler exits. So you must either turn streaming off in your StreamHandler, or make sure that the StreamHandler will be called again. This last is done by sending data to the client. If for some reason you have no data to send, you can get the same result with "continue". Remember that this will also cause the StreamHandler to be called one more time. my $aliases=POE::Component::Filter::HTTP->new( ....); # and then, when the end of the stream in met $response->close; $response->continue; NOTE: even when the stream ends, the client connection will be held open if Keepalive is active. To force the connection closed, set the Connection header to close: $resquest->header(Connection => 'close'); This might be a bug. Are there any cases where we'd want to keep the connection open after a stream? Events The "shutdown" event may be sent to the component indicating that it should shut down. The event may be sent using the return value of the new() method (which is a session id) by either post()ing or call()ing. I've experienced some problems with the session not receiving the event when it gets post()ed so call() is advised. See Also Please also take a look at HTTP::Response, HTTP::Request, URI, POE and POE::Filter::HTTPD TODO
Document Connection Response and Request objects. Write more tests Add a PoCo::Server::HTTP::Session that matches a http session against poe session using cookies or other state system Add more options to streaming Figure out why post()ed "shutdown" events don't get received. Probably lots of other API changes AUTHOR
Arthur Bergman, arthur@contiller.se Additional hacking by Philip Gwyn, poe-at-pied.nu Released under the same terms as POE. perl v5.10.0 2006-05-23 POE::Component::Server::HTTP(3pm)
All times are GMT -4. The time now is 04:26 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy