How to parse a text file through PERL into MySQL?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • akshay mokhalga
    New Member
    • Dec 2010
    • 5

    How to parse a text file through PERL into MySQL?

    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??
  • chorny
    Recognized Expert New Member
    • Jan 2008
    • 80

    #2
    If this report is in CSV format, you can use Text::CSV module to parse it.

    Comment

    • numberwhun
      Recognized Expert Moderator Specialist
      • May 2007
      • 3467

      #3
      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

      Comment

      • akshay mokhalga
        New Member
        • Dec 2010
        • 5

        #4
        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.
        Last edited by numberwhun; Dec 19 '10, 05:49 PM. Reason: Please DO NOT post IPs or personal information in the forums!

        Comment

        • chorny
          Recognized Expert New Member
          • Jan 2008
          • 80

          #5
          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.

          Comment

          • numberwhun
            Recognized Expert Moderator Specialist
            • May 2007
            • 3467

            #6
            @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

            Comment

            • akshay mokhalga
              New Member
              • Dec 2010
              • 5

              #7
              @Jeff:-ok Jeff I will take care of this in future....

              Comment

              • numberwhun
                Recognized Expert Moderator Specialist
                • May 2007
                • 3467

                #8
                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

                Comment

                • akshay mokhalga
                  New Member
                  • Dec 2010
                  • 5

                  #9
                  I have one more question how can I call a perl program through C compiler??

                  Comment

                  • chorny
                    Recognized Expert New Member
                    • Jan 2008
                    • 80

                    #10
                    > 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.

                    Comment

                    Working...