hello im new with perl
i must do parse log file from networker
with format look like this :
Start time: 2-16-07 11:27a
Recovering files of client 'blablabla' from server 'bliblibli'.
Recover: Total estimated disk space needed for recover is 3 MB.
Recovering 5 files within D:\X\Y\ into E:\restore
Requesting 5 file(s), this may take a while...
E:\restore\blab la\blablabla.bl a
E:\restore\blab la\blablabla.bl i
E:\restore\blab la\blablabla.bl u
E:\restore\blab la\blablabla.bl e
E:\restore\blab la\blablabla.bl o
Received 5 file(s) from NSR server 'blablabla'
Recover completion time: Fri Feb 16 11:30:52 2007
and the data,i need:
start time,completion time,client name,server name,total file,and disk space
i have problem with regex,grep,spli t..is anyone can help me?
thx before =)
Jun 18 '07
21 2622 KevinADC 4,059
Recognized Expert Specialist
You need a way to skip the lines that don't interest you and find the ones that do. You can use a regexp to do that. Since this is school work I leave that up to you to figure out.
You need a way to skip the lines that don't interest you and find the ones that do. You can use a regexp to do that. Since this is school work I leave that up to you to figure out.
skip the line??
sorry i dont get it
yea im gonna figure it out..do i have the right step?
KevinADC 4,059
Recognized Expert Specialist
Your entire approach is really quite awkward but I have no idea how far along you are in your perl studies. If you have already covered regular expressions you should be using them to find the lines you want to parse data out of. But maybe the assignment dictates what functions you have to use to get the output.
As far as skipping goes, these lines do not seem to interest you:
E:\restore\blab la\blablabla.bl a
E:\restore\blab la\blablabla.bl i
E:\restore\blab la\blablabla.bl u
E:\restore\blab la\blablabla.bl e
E:\restore\blab la\blablabla.bl o
so you would skip them (move on to the next line) until you find a line that does interest you.
im sorry..but im new in perl..
any advise for my code?
thx
KevinADC 4,059
Recognized Expert Specialist
any advise for my code?
Yes, use regular expressions to parse the data to get the results you want.
use regular expressions to parse the data to get the results you want.
mmh oke..but is my code wrong?
or regular expression make it easier?
KevinADC 4,059
Recognized Expert Specialist
mmh oke..but is my code wrong?
or regular expression make it easier?
There is no way for me to know if your code is wrong. That depends on how much perl you have learned already and how much you are expected to know at this point in your studies.
Technically, if the code runs and poduces the correct results, it's good code. It may not be efficient code, but it's good. Your code is close to producing the results you want.
Using regular expressions should make the job easier.
thx so much
another question,can you help me
Recovering 10 files within C:\ABC\DEF\ into F:\XYZ\PQR\
data i need C:\ABC\DEF\ and F:\XYZ\PQR\
how regular expression solve this thing?
KevinADC 4,059
Recognized Expert Specialist
OK you beat some code out of me, but since this is your school work don't expect anymore code. This is one possible way to match the pattern you are interested in: - $line = 'Recovering 5 files within D:\X\Y\ into E:\restore';
-
if ($line =~ /^Recovering \d+ files within (\S+) into (\S+)/ ) {
-
print "$1 $2";
-
}
here are a couple of regexp tutorials:
# perlrequick - Perl regular expressions quick start
# perlretut - Perl regular expressions tutorial
you can find them here: http://perldoc.perl.org/index-tutorials.html
thx so much..
im gonna try it =)
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Willem Ligtenberg |
last post by:
I decided to use SAX to parse my xml file.
But the parser crashes on:
File "/usr/lib/python2.3/site-packages/_xmlplus/sax/handler.py", line 38, in fatalError
raise exception
xml.sax._exceptions.SAXParseException: NCBI_Entrezgene.dtd:8:0: error in processing external entity reference
This is caused by:
<!DOCTYPE Entrezgene-Set PUBLIC "-//NCBI//NCBI Entrezgene/EN"
"NCBI_Entrezgene.dtd">
|
by: Cigdem |
last post by:
Hello,
I am trying to parse the XML files that the user selects(XML files are
on anoher OS400 system called "wkdis3"). But i am permenantly getting
that error:
Directory0: \\wkdis3\ROOT\home
Canonicalpath-Directory4: \\wkdis3\ROOT\home\bwe\
You selected the file named AAA.XML
getXmlAlgorithmDocument(): IOException Not logged in
|
by: Pir8 |
last post by:
I have a complex xml file, which contains stories within a magazine. The
structure of the xml file is as follows:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<magazine>
<story>
<story_id>112233</story_id>
<pub_name>Puleen's Publication</pub_name>
<pub_code>PP</pub_code>
<edition_date>20031201</edition_date>
|
by: Christoph Bisping |
last post by:
Hello!
Maybe someone is able to give me a little hint on this:
I've written a vb.net app which is mainly an interpreter for specialized
CAD/CAM files.
These files mainly contain simple movement and drawing instructions like
"move to's" and "change color's" optionally followed by one or more numeric
(int or float) arguments. My problem is that the parsing algorithm I've
currently implemented is extremely slow.
|
by: Rick Walsh |
last post by:
I have an HTML table in the following format:
<table>
<tr><td>Header 1</td><td>Header 2</td></tr>
<tr><td>1</td><td>2</td></tr>
<tr><td>3</td><td>4</td></tr>
<tr><td>5</td><td>6</td></tr>
</table>
With an XSLT styles sheet, I can use for-each to grab the values in
| |
by: toton |
last post by:
Hi,
I have some ascii files, which are having some formatted text. I want
to read some section only from the total file.
For that what I am doing is indexing the sections (denoted by .START
in the file) with the location.
And for a particular section I parse only that section.
The file is something like,
.... DATAS
|
by: Paulers |
last post by:
Hello,
I have a log file that contains many multi-line messages. What is the
best approach to take for extracting data out of each message and
populating object properties to be stored in an ArrayList? I have tried
looping through the logfile using regex, if statements and flags to
find the start and end of each message but I do not see a good time in
this process to create a new instance of my Message object. While
messing around with...
|
by: Chris Carlen |
last post by:
Hi:
Having completed enough serial driver code for a TMS320F2812
microcontroller to talk to a terminal, I am now trying different
approaches to command interpretation.
I have a very simple command set consisting of several single letter
commands which take no arguments. A few additional single letter
commands take arguments:
|
by: charliefortune |
last post by:
I am fetching some product feeds with PHP like this
$merch = substr($key,1);
$feed = file_get_contents($_POST);
$fp = fopen("./feeds/feed".$merch.".txt","w+");
fwrite ($fp,$feed);
fclose ($fp);
and then parsing them with PHP's native parsing functions. This is
succesful for most of the feeds, but a couple of them claim to be
|
by: Felipe De Bene |
last post by:
I'm having problems parsing an HTML file with the following syntax :
<TABLE cellspacing=0 cellpadding=0 ALIGN=CENTER BORDER=1 width='100%'>
<TH BGCOLOR='#c0c0c0' Width='3%'>User ID</TH>
<TH Width='10%' BGCOLOR='#c0c0c0'>Name</TH><TH width='7%'
BGCOLOR='#c0c0c0'>Date</TH>
and so on....
whenever I feed the parser with such file I get the error :
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |