Sponsored Content
Top Forums Shell Programming and Scripting Substring/Instring of a string with datestamp Post 302161320 by alamitab on Thursday 24th of January 2008 08:13:00 AM
Old 01-24-2008
echo JAN_BILS_PRINT_01-01-08.txt | cut -b16-23 | sed 's/-/\//g'
 

10 More Discussions You Might Find Interesting

1. Programming

can i get a substring from a string?

for example, the string a is "abcdefg", can i get a substring "bcd" (from ato a) from string a? thank you (4 Replies)
Discussion started by: dell9
4 Replies

2. Shell Programming and Scripting

getting a substring from a string

hi all, I am trying to extract SUBSTRINGS out of a string using ksh. The string is "SAPR3K.FD0.FA.TJ.B0010.T050302" I tried using a= `expr substr $stringZ 1 2` which is giving me a syntax error, donno why?? any ideas why its not working?? I also tried echo "welcome" | awk '{... (3 Replies)
Discussion started by: maradona
3 Replies

3. UNIX for Dummies Questions & Answers

How to get the substring from the string

Hi All, Can anybody help me to get the substring from the given string. (3 Replies)
Discussion started by: Anshu
3 Replies

4. Shell Programming and Scripting

get substring from string

Hi All, Problem Description: XML_REP_REQUEST=`CONCSUB "$LOGIN" "SQLAP" "$RESP_NAME" "$USRNM" WAIT="Y" "CONCURRENT" "APPLICATION_SHORT_NAME" "CP_SHORT_NAME"` echo Report Request: $XML_REP_REQUEST --to print value in log file While execution the value of 'XML_REP_REQUEST' is 'Prozess... (5 Replies)
Discussion started by: suman.g
5 Replies

5. Shell Programming and Scripting

Help with string and substring also I/O

#!/bin/sh PRINTF=/usr/bin/printf PASSWD=/etc/passwd $PRINTF "Enter a UserID\n" read USERID if ; then $PRINTF "$USERID does not exist, please contact IT service\n" exit 1 fi USERHOME=`grep "^$USERID:" $PASSWD | awk -F : '{print $6}'` USERSHELL=`grep "^$USERID:"... (1 Reply)
Discussion started by: ikeQ
1 Replies

6. Shell Programming and Scripting

Substring in string with whitespaces

hello, i have this string: variable="1234 /PARAMETER_1:text /PARAMETER_2:othertext" i tried to do expr match $variable '.*\(*\)' but i keep getting expr error i need to extract the word text... thank you (4 Replies)
Discussion started by: Aloush89
4 Replies

7. Shell Programming and Scripting

Instring in awk

Hi, I have the below data ownername/schemaname/tablename/columnname in a file ( 2nd column) I want to convert everthing to upper case except the column name like below OWNERNAME/SCHEMANAME/TABLENAME/columnname do we have a instring function in awk to handle this. Thx,shruthi (3 Replies)
Discussion started by: shruthidwh
3 Replies

8. Shell Programming and Scripting

How to extract a substring from a string

Hi, I have an input string say for example: ABC,DEF,IJK,LMN,...,XYZ The above string is comma delimited. Now I have to extract the last part after the comma i.e. XYZ. :b: (3 Replies)
Discussion started by: bghosh
3 Replies

9. UNIX for Dummies Questions & Answers

get substring from string variable

Hi Dears, How to use variable in string location of expression ${string:index:length} to get substring from string? I encounter error "bad substitution" when I use expression ${$var:0:5} to get first 5 characters from $var. Could you please help me out of this? Thanks! (2 Replies)
Discussion started by: crest.boy
2 Replies

10. Shell Programming and Scripting

Extracting substring within string between 2 token within the string

Hello. First best wishes for everybody. here is the input file ("$INPUT1") contents : BASH_FUNC_message_begin_script%%=() { local -a L_ARRAY; BASH_FUNC_message_debug%%=() { local -a L_ARRAY; BASH_FUNC_message_end_script%%=() { local -a L_ARRAY; BASH_FUNC_message_error%%=() { local... (3 Replies)
Discussion started by: jcdole
3 Replies
HTTP::OAI::Harvester(3pm)				User Contributed Perl Documentation				 HTTP::OAI::Harvester(3pm)

NAME
HTTP::OAI::Harvester - Agent for harvesting from Open Archives version 1.0, 1.1, 2.0 and static ('2.0s') compatible repositories DESCRIPTION
"HTTP::OAI::Harvester" is the harvesting front-end in the OAI-PERL library. To harvest from an OAI-PMH compliant repository create an "HTTP::OAI::Harvester" object using the baseURL option and then call OAI-PMH methods to request data from the repository. To handle version 1.0/1.1 repositories automatically you must request "Identify()" first. It is recommended that you request an Identify from the Repository and use the "repository()" method to update the Identify object used by the harvester. When making OAI requests the underlying HTTP::OAI::UserAgent module will take care of automatic redirection (http code 302) and retry-after (http code 503). OAI-PMH flow control (i.e. resumption tokens) is handled transparently by "HTTP::OAI::Response". Static Repository Support Static repositories are automatically and transparently supported within the existing API. To harvest a static repository specify the repository XML file using the baseURL argument to HTTP::OAI::Harvester. An initial request is made that determines whether the base URL specifies a static repository or a normal OAI 1.x/2.0 CGI repository. To prevent this initial request state the OAI version using an HTTP::OAI::Identify object e.g. $h = HTTP::OAI::Harvester->new( repository=>HTTP::OAI::Identify->new( baseURL => 'http://arXiv.org/oai2', version => '2.0', )); If a static repository is found the response is cached, and further requests are served by that cache. Static repositories do not support sets, and will result in a noSetHierarchy error if you try to use sets. You can determine whether the repository is static by checking the version ($ha->repository->version), which will be "2.0s" for static repositories. FURTHER READING
You should refer to the Open Archives Protocol version 2.0 and other OAI documentation, available from http://www.openarchives.org/. Note OAI-PMH 1.0 and 1.1 are deprecated. BEFORE USING EXAMPLES
In the examples I use arXiv.org's and cogprints OAI interfaces. To avoid causing annoyance to their server administrators please contact them before performing testing or large downloads (or use other, less loaded, servers for testing). SYNOPSIS
use HTTP::OAI; my $h = new HTTP::OAI::Harvester(baseURL=>'http://arXiv.org/oai2'); my $response = $h->repository($h->Identify) if( $response->is_error ) { print "Error requesting Identify: ", $response->code . " " . $response->message, " "; exit; } # Note: repositoryVersion will always be 2.0, $r->version returns # the actual version the repository is running print "Repository supports protocol version ", $response->version, " "; # Version 1.x repositories don't support metadataPrefix, # but OAI-PERL will drop the prefix automatically # if an Identify was requested first (as above) $response = $h->ListIdentifiers( metadataPrefix=>'oai_dc', from=>'2001-02-03', until=>'2001-04-10' ); if( $response->is_error ) { die("Error harvesting: " . $response->message . " "); } print "responseDate => ", $response->responseDate, " ", "requestURL => ", $response->requestURL, " "; while( my $id = $response->next ) { print "identifier => ", $id->identifier; # Only available from OAI 2.0 repositories print " (", $id->datestamp, ")" if $id->datestamp; print " (", $id->status, ")" if $id->status; print " "; # Only available from OAI 2.0 repositories for( $id->setSpec ) { print " ", $_, " "; } } # Using a handler $response = $h->ListRecords( metadataPrefix=>'oai_dc', handlers=>{metadata=>'HTTP::OAI::Metadata::OAI_DC'}, ); while( my $rec = $response->next ) { print $rec->identifier, " ", $rec->datestamp, " ", $rec->metadata, " "; print join(',', @{$rec->metadata->dc->{'title'}}), " "; } if( $rec->is_error ) { die $response->message; } # Offline parsing $I = HTTP::OAI::Identify->new(); $I->parse_string($content); $I->parse_file($fh); METHODS
HTTP::OAI::Harvester->new( %params ) This constructor method returns a new instance of "HTTP::OAI::Harvester". Requires either an HTTP::OAI::Identify object, which in turn must contain a baseURL, or a baseURL from which to construct an Identify object. Any other parameters are passed to the HTTP::OAI::UserAgent module, and from there to the LWP::UserAgent module. $h = HTTP::OAI::Harvester->new( baseURL => 'http://arXiv.org/oai2', resume=>0, # Suppress automatic resumption ) $id = $h->repository(); $h->repository($h->Identify); $h = HTTP::OAI::Harvester->new( HTTP::OAI::Identify->new( baseURL => 'http://arXiv.org/oai2', )); $h->repository() Returns and optionally sets the HTTP::OAI::Identify object used by the Harvester agent. $h->resume( [1] ) If set to true (default) resumption tokens will automatically be handled by requesting the next partial list during "next()" calls. OAI-PMH Verbs The 6 OAI-PMH Verbs are the requests supported by an OAI-PMH interface. Error Messages Use "is_success()" or "is_error()" on the returned object to determine whether an error occurred (see HTTP::OAI::Response). "code()" and "message()" return the error code (200 is success) and a human-readable message respectively. Errors returned by the repository can be retrieved using the "errors()" method: foreach my $error ($r->errors) { print $error->code, " ", $error->message, " "; } Note: "is_success()" is true for the OAI Error Code "noRecordsMatch" (i.e. empty set), although "errors()" will still contain the OAI error. Flow Control If the response contained a resumption token this can be retrieved using the $r->resumptionToken method. Methods These methods return an object subclassed from HTTP::Response (where the class corresponds to the verb requested, e.g. "GetRecord" requests return an "HTTP::OAI::GetRecord" object). $r = $h->GetRecord( %params ) Get a single record from the repository identified by identifier, in format metadataPrefix. $gr = $h->GetRecord( identifier => 'oai:arXiv:hep-th/0001001', # Required metadataPrefix => 'oai_dc' # Required ); $rec = $gr->next; die $rec->message if $rec->is_error; printf("%s (%s) ", $rec->identifier, $rec->datestamp); $dom = $rec->metadata->dom; $r = $h->Identify() Get information about the repository. $id = $h->Identify(); print join ',', $id->adminEmail; $r = $h->ListIdentifiers( %params ) Retrieve the identifiers, datestamps, sets and deleted status for all records within the specified date range (from/until) and set spec (set). 1.x repositories will only return the identifier. Or, resume an existing harvest by specifying resumptionToken. $lr = $h->ListIdentifiers( metadataPrefix => 'oai_dc', # Required from => '2001-10-01', until => '2001-10-31', set=>'physics:hep-th', ); while($rec = $lr->next) { { ... do something with $rec ... } } die $lr->message if $lr->is_error; $r = $h->ListMetadataFormats( %params ) List available metadata formats. Given an identifier the repository should only return those metadata formats for which that item can be disseminated. $lmdf = $h->ListMetadataFormats( identifier => 'oai:arXiv.org:hep-th/0001001' ); for($lmdf->metadataFormat) { print $_->metadataPrefix, " "; } die $lmdf->message if $lmdf->is_error; $r = $h->ListRecords( %params ) Return full records within the specified date range (from/until), set and metadata format. Or, specify a resumption token to resume a previous partial harvest. $lr = $h->ListRecords( metadataPrefix=>'oai_dc', # Required from => '2001-10-01', until => '2001-10-01', set => 'physics:hep-th', ); while($rec = $lr->next) { { ... do something with $rec ... } } die $lr->message if $lr->is_error; $r = $h->ListSets( %params ) Return a list of sets provided by the repository. The scope of sets is undefined by OAI-PMH, so therefore may represent any subset of a collection. Optionally provide a resumption token to resume a previous partial request. $ls = $h->ListSets(); while($set = $ls->next) { print $set->setSpec, " "; } die $ls->message if $ls->is_error; AUTHOR
These modules have been written by Tim Brody <tdb01r@ecs.soton.ac.uk>. perl v5.12.4 2011-06-23 HTTP::OAI::Harvester(3pm)
All times are GMT -4. The time now is 04:08 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy