473,668 Members | 2,428 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to parse a text file through PERL into MySQL?

5 New Member
I have to make a project on Vulnerability Management System so I've generated a text report related to vulnerability scan. Now I have to parse this report into mysql. So please tell me how can I do this??
Dec 18 '10 #1
9 2625
chorny
80 Recognized Expert New Member
If this report is in CSV format, you can use Text::CSV module to parse it.
Dec 18 '10 #2
numberwhun
3,509 Recognized Expert Moderator Specialist
Easy, use Perl. :) I know, simplistic answer.

The hard part is we have no clue what this report looks like. If the report is a list of lines, each containing a set of data, then you could split each line into its parts and input the data into the database using DBI. No matter what format it is, you just need to figure out how to parse each element you need out, then use DBI to input the data into the db table(s) you create(d).

Write code and do what you can. If you have issues with the coding, post your code and data samples here and we will help you where you get stuck.

Regards,

Jeff
Dec 18 '10 #3
akshay mokhalga
5 New Member
The file type is .nbe . I show a sample type of that file:
results|IP REMOVED|IP REMOVED|general/udp|10287|Secur ity Note|\nSynopsis :\n\nIt was possible to obtain traceroute information.\n\ nDescription :\n\nMakes a traceroute to the remote host.\n\nSoluti on :\n\nn/a\n\nRisk factor :\n\nNone\n\nPl ugin output :\n\nFor your information, here is the traceroute from IP REMOVED to IP REMOVED : \nIP REMOVED\nIP REMOVED\n\n
This is a small part of that file so tell me how I can do parsing of this file also tell me what pattern I can follow to parse it.
Dec 19 '10 #4
chorny
80 Recognized Expert New Member
You should have started with information that you use Nessus.
Try Parse::Nessus:: NBE from CPAN. It is old, but if .nbe format did not change, it will work.
Dec 19 '10 #5
numberwhun
3,509 Recognized Expert Moderator Specialist
@akshay mokhalga Please do not post IP Addresses, Email addresses, or any other personal information in the forums. Information posted here is scrapable from the internet and not guarded as it would be on private sites.
I have removed your IP information, please be more mindful next time.

Regards,

Jeff
Dec 19 '10 #6
akshay mokhalga
5 New Member
@Jeff:-ok Jeff I will take care of this in future....
Dec 19 '10 #7
numberwhun
3,509 Recognized Expert Moderator Specialist
Also, using quote tags around your samples better separates the sample from the rest of the post's text, that way we don't have to guess what your sample is and what your comment is.

Regards,

Jeff
Dec 19 '10 #8
akshay mokhalga
5 New Member
I have one more question how can I call a perl program through C compiler??
Dec 27 '10 #9
chorny
80 Recognized Expert New Member
> I have one more question how can I call a perl program through C compiler??

1. You can use exec or system (I don't remember this part of C, so you need to look yourself).

2. You can embed Perl into your program. See perlembed.pod.
Dec 27 '10 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

0
11997
by: John M. Lembo | last post by:
I am using Perl to parse a text file and output to another file. The text file has data on Unix virtual memory (vmstat) and I want to delete lines that I don't want and output lines that I want to a new file. The script I have is giving me blank lines in the new file. #!/usr/local/bin/perl #program to read systemdata file #and write to systemstats file # #
2
12075
by: Tyaan | last post by:
Hi.. I'm a perl noob need to know how to write a script to parse a file containing one to four of the following blocks of text? I then want to print the results in a format showing the memory size (128) for each device that was found? Structure: Memory Device (Type 17) Type: 17 Length: 15h Handle: 0024h (36t) Memory Array Handle: 0021
2
1601
by: Jamie | last post by:
A B C D E F G H I J K L M N O P Q R insert into test (building,dep,owner,pcdesc,host,pctag,os,sp) values (' A ,' Catering ,' User 3 ,' EVO N410 ,' PC24346 ,' TAG-24346 ,' WIN 2000 ,' 4 ); insert into test (building,dep,owner,pcdesc,host,pctag,os,sp) values (' A ,' Catering ,' User 4 ,' EVO N610 ,' PC24950 ,' TAG-24950 ,' WIN 2000 ,' 4 ); insert into test (building,dep,owner,pcdesc,host,pctag,os,sp) values (' A ,' Catering ,' User 5 ,'...
2
15609
by: Sacha Korell | last post by:
How would I check for an end of file when parsing a text file using the StreamReader object? I would like to do something like this: '******************************** Dim objStreamReader As StreamReader Dim strReqLine As String objStreamReader = File.OpenText("data.txt")
3
18709
by: boukaka | last post by:
Hi there, I have a text file that does not have any delimiters - it is simply assumed that I know how long each field is and they are always in the same order. (i.e. JOHN DOE 12345606JUN072007JUL2009 34 PXP) Using C# I need to: 1. Grab the information in the text file. 2. Parse it out by grabbing the different "fields" (5th to 9th char = name, 24th to 27th is product etc). 3. Sort the fields into the order I want...
0
1418
by: ramaraog80 | last post by:
Hi, I want VB Script which exports data from a text file to MySql Tables. Please help me regarding this. Regards Ramarao G
2
2131
by: kkazakos | last post by:
Hello, I am a newbie in perl and i have the following problem. I have as input a text file in the following format: ================================================================================ 5/24/07 5:35:50 PM : Finished to read one line : r 250 1006 -63 -65 91 -6 -8 319* 5/24/07 5:35:50 PM : Successfully opened DB. 5/24/07 5:35:50 PM : Going to read one line. 5/24/07 5:35:50 PM : Going to close DB. 5/24/07 5:35:50 PM :...
3
1974
by: vaibhavkansara | last post by:
Hello friends, I am vaibhav I am a new to PHP/MYSQL.I have a problem to uploading a text file into MYSQL using php, and a text file is a tabdelimited file so pleas give me solution as soon as possible .Thanks in advance. Vaibhav
12
4413
by: mantrid | last post by:
Hello Can anyone point me in the right direction for the way to read a text file a line at a time and separate the fields on that line and use them as data in an INSERT to add a record to a mysql table. Then read the second line in text file and repeat. Thanks for your time Ian
1
2957
by: Noorain | last post by:
sir my data are in text file. i want import text file in mysql data to use php script. please help me............. my text file is 1#AA#2,345.00 2#BB#850.00 3#CC#31,855.00
0
8462
marktang
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...
0
8382
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,...
0
8893
Oralloy
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...
0
8802
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8586
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,...
0
8658
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7405
agi2029
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...
1
6209
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
2792
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.