Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Create html <ui> <li> by parsing text file Post 303040320 by alcresio on Saturday 26th of October 2019 12:50:27 PM
Old 10-26-2019
Yes Neo,
my code works, but it's really ugly! :-)

It was written by hand just to give an idea. The formatting code make clearer the future steps. Tnx!


I stiil working on basics of scripting, May I need some time to learn.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How do I extract text only from html file without HTML tag

I have a html file called myfile. If I simply put "cat myfile.html" in UNIX, it shows all the html tags like <a href=r/26><img src="http://www>. But I want to extract only text part. Same problem happens in "type" command in MS-DOS. I know you can do it by opening it in Internet Explorer,... (4 Replies)
Discussion started by: los111
4 Replies

2. Shell Programming and Scripting

Create a html file if a process is running??

Hi All, I need to check for a process, if the process is running then I have to create an HTML file, say A.HTML. If the process is not running then I have to rename the existing html, say A.HTML to B.HTML so that the process which looks for the file A.HTML does not find it? How do I do... (1 Reply)
Discussion started by: Hangman2
1 Replies

3. Shell Programming and Scripting

Create multiple text file from a single text file on AIX

Hi I need to create multiple text files from onc text file on AIX. The data of text files is as below: ********************************************** ********************************************** DBVERIFY: Release 10.2.0.4.0 - Production on Tue Nov 10 13:45:42 2009 Copyright (c) 1982,... (11 Replies)
Discussion started by: lodhi1978
11 Replies

4. Shell Programming and Scripting

Linux Script create index.html file

I need a script that can do this: A script that searches all directories and subdirectories for .html files When a .html file is found it creates a index.html file in that folder. It then edits the index.html file and inserts links to all of the .html files that are in that folder into the... (5 Replies)
Discussion started by: seashell11
5 Replies

5. Programming

Parsing a Text file using C++

I was trying to parse the text file, which will looks like this ###XYZABC#### ############ int = 4 char = 1 float = 1 . . ############ like this my text file will contains lots of entries and I need to store these entries in the map eg. map.first = int and map.second = 4 same way I... (5 Replies)
Discussion started by: agupta2
5 Replies

6. Shell Programming and Scripting

Script to create a text file whose content is the text of another files

Hello everyone, I work under Ubuntu 11.10 (c-shell) I need a script to create a new text file whose content is the text of another text files that are in the directory $DIRMAIL at this moment. I will show you an example: - On the one hand, there is a directory $DIRMAIL where there are... (1 Reply)
Discussion started by: tenteyu
1 Replies

7. Shell Programming and Scripting

Parsing HTML, get text between 2 HTML tags

Hi there, I'm quite new to the forum and shell scripting. I want to filter out the "166.0 points". The results, that i found in google / the forum search didn't helped me :( <a href="/user/test" class="headitem menu" style="color:rgb(83,186,224);">test</a><a href="/points" class="headitem... (1 Reply)
Discussion started by: Mysthik
1 Replies

8. Shell Programming and Scripting

awk parsing file to create a database

Hi Guys, I have a list a hotels stored in many different text files. This list is kept in the following format: 20/03 Hotel: The Bear Hotel Honey Street Woodstock UK Tel:+44-xxxxxx Rate: 100 21/03 Hotel: The Bush Hotel Nice Street Farnham (4 Replies)
Discussion started by: freddie50
4 Replies

9. Linux

Parsing - export html table data as .csv file?

Hi all, Is there any out there have a brilliant idea on how to export html table data as .csv or write to txt file with separated comma and also get the filename of link from every table and put one line per rows each table. Please see the attached html and PNG of what it looks like. ... (7 Replies)
Discussion started by: lxdorney
7 Replies

10. UNIX for Beginners Questions & Answers

Copy the content from txt file and create a html file

I have a txt file with a list of error messages in a xml tag format, and each error message is separated with a identifier(endresult).Need to split that and copy and create a new html file.Error message has some special character. how to escape the special character and insert my data into the... (7 Replies)
Discussion started by: DevAakash
7 Replies
apache_mod_perl-108~358::mod_perl-2.0.7::docs::api::APR:UseroContributed Perl Docapache_mod_perl-108~358::mod_perl-2.0.7::docs::api::APR::Error(3)

NAME
APR::Error - Perl API for APR/Apache/mod_perl exceptions Synopsis eval { $obj->mp_method() }; if ($@ && $ref $@ eq 'APR::Error' && $@ == $some_code) { # handle the exception } else { die $@; # rethrow it } Description "APR::Error" handles APR/Apache/mod_perl exceptions for you, while leaving you in control. Apache and APR API return a status code for almost all methods, so if you didn't check the return code and handled any possible problems, you may have silent failures which may cause all kind of obscure problems. On the other hand checking the status code after each call is just too much of a kludge and makes quick prototyping/development almost impossible, not talking about the code readability. Having methods return status codes, also complicates the API if you need to return other values. Therefore to keep things nice and make the API readable we decided to not return status codes, but instead throw exceptions with "APR::Error" objects for each method that fails. If you don't catch those exceptions, everything works transparently - perl will intercept the exception object and "die()" with a proper error message. So you get all the errors logged without doing any work. Now, in certain cases you don't want to just die, but instead the error needs to be trapped and handled. For example if some IO operation times out, may be it is OK to trap that and try again. If we were to die with an error message, you would have had to match the error message, which is ugly, inefficient and may not work at all if locale error strings are involved. Therefore you need to be able to get the original status code that Apache or APR has generated. And the exception objects give you that if you want to. Moreover the objects contain additional information, such as the function name (in case you were eval'ing several commands in one block), file and line number where that function was invoked from. More attributes could be added in the future. "APR::Error" uses Perl operator overloading, such that in boolean and numerical contexts, the object returns the status code; in the string context the full error message is returned. When intercepting exceptions you need to check whether $@ is an object (reference). If your application uses other exception objects you additionally need to check whether this is a an "APR::Error" object. Therefore most of the time this is enough: eval { $obj->mp_method() }; if ($@ && $ref $@ && $@ == $some_code) warn "handled exception: $@"; } But with other, non-mod_perl, exception objects you need to do: eval { $obj->mp_method() }; if ($@ && $ref $@ eq 'APR::Error' && $@ == $some_code) warn "handled exception: $@"; } In theory you could even do: eval { $obj->mp_method() }; if ($@ && $@ == $some_code) warn "handled exception: $@"; } but it's possible that the method will die with a plain string and not an object, in which case "$@ == $some_code" won't quite work. Remember that mod_perl throws exception objects only when Apache and APR fail, and in a few other special cases of its own (like "exit"). warn "handled exception: $@" if $@ && $ref $@; There are two ways to figure out whether an error fits your case. In most cases you just compare $@ with an the error constant. For example if a socket has a timeout set and the data wasn't read within the timeout limit a "APR::Const::TIMEUP") use APR::Const -compile => qw(TIMEUP); $sock->timeout_set(1_000_000); # 1 sec my $buff; eval { $sock->recv($buff, BUFF_LEN) }; if ($@ && ref $@ && $@ == APR::Const::TIMEUP) { } However there are situations, where on different Operating Systems a different error code will be returned. In which case to simplify the code you should use the special subroutines provided by the "APR::Status" class. One such condition is socket "recv()" timeout, which on Unix throws the "EAGAIN" error, but on other system it throws a different error. In this case "APR::Status::is_EAGAIN" should be used. Let's look at a complete example. Here is a code that performs a socket read: my $rlen = $sock->recv(my $buff, 1024); warn "read $rlen bytes "; and in certain cases it times out. The code will die and log the reason for the failure, which is fine, but later on you may decide that you want to have another attempt to read before dying and add some fine grained sleep time between attempts, which can be achieved with "select". Which gives us: use APR::Status (); # .... my $tries = 0; my $buffer; RETRY: my $rlen = eval { $sock->recv($buffer, SIZE) }; if ($@) die $@ unless ref $@ && APR::Status::is_EAGAIN($@); if ($tries++ < 3) { # sleep 250msec select undef, undef, undef, 0.25; goto RETRY; } else { # do something else } } warn "read $rlen bytes " Notice that we handle non-object and non-"APR::Error" exceptions as well, by simply re-throwing them. Finally, the class is called "APR::Error" because it needs to be used outside mod_perl as well, when called from "APR" applications written in Perl. API
"cluck" "cluck" is an equivalent of "Carp::cluck" that works with "APR::Error" exception objects. "confess" "confess" is an equivalent of "Carp::confess" that works with "APR::Error" exception objects. "strerror" Convert APR error code to its string representation. $error_str = APR::Error::strerror($rc); ret: $rc ( "APR::Const status constant" ) The numerical value for the return (error) code ret: $error_str ( string ) The string error message corresponding to the numerical value inside $rc. (Similar to the C function strerror(3)) since: 2.0.00 Example: Try to retrieve the bucket brigade, and if the return value doesn't indicate success or end of file (usually in protocol handlers) die, but give the user the human-readable version of the error and not just the code. my $rc = $c->input_filters->get_brigade($bb_in, Apache2::Const::MODE_GETLINE); if ($rc != APR::Const::SUCCESS && $rc != APR::Const::EOF) { my $error = APR::Error::strerror($rc); die "get_brigade error: $rc: $error "; } It's probably a good idea not to omit the numerical value in the error message, in case the error string is generated with non-English locale. See Also mod_perl 2.0 documentation. Copyright mod_perl 2.0 and its core modules are copyrighted under The Apache Software License, Version 2.0. Authors The mod_perl development team and numerous contributors. perl v5.16.2 2011-02-07 apache_mod_perl-108~358::mod_perl-2.0.7::docs::api::APR::Error(3)
All times are GMT -4. The time now is 01:58 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy