Justtechjobs.com Find a programming school near you






Online Campus Both


php-general | 2001032

Re: [PHP] fscanf syntax From: Chris Fry (chris <email protected>)
Date: 03/30/01

Pat,

You could read the file into an array;

$aryNessus = file("/pathtofile/filename", "r");

Each row of the array then has one line from the file;
Get the record count;
$intNumRecs = count($aryNessus);

Now read through the array and extract the values;

for($i=0;$i<=$intNumRecs;$i++) {
    $aryNessusFields = explode("|", $aryNessus[$i]);
    $hostname = $aryNessusFields[0];
    $protocol = $aryNessusFields[1];
    $number = $aryNessusFields[2];
    $severity = $aryNessusFields[3];
    $description + $aryNessusFields[4];
    // Save the data into the database here
}

Regards

Chris

Patrick Brown wrote:

> I want to parse a file with the following syntax.
>
> hostname|protocol|number|severity|description
>
> Each record is on it's own line and have the fields delimited by the pipe
> character |. The file may have thousands of records and I would like to
> bring them into a database for reporting.
>
> Some of you may recognize this a the file format of a Nessus security scan
> file.
>
> What function should I use and what would the syntax be?
>
> Thanks,
> Pat
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe <email protected>
> For additional commands, e-mail: php-general-help <email protected>
> To contact the list administrators, e-mail: php-list-admin <email protected>

--
Chris Fry
Quillsoft Pty Ltd
Specialists in Secure Internet Services and E-Commerce Solutions
10 Gray Street
Kogarah
NSW  2217
Australia

Phone: +61 2 9553 1691 Fax: +61 2 9553 1692 Mobile: 0419 414 323 eMail: chris <email protected> http://www.quillsoft.com.au

You can download our Public CA Certificate from:- https://ca.secureanywhere.com/htdocs/cacert.crt

**********************************************************************

This information contains confidential information intended only for the use of the authorised recipient. If you are not an authorised recipient of this e-mail, please contact Quillsoft Pty Ltd by return e-mail. In this case, you should not read, print, re-transmit, store or act in reliance on this e-mail or any attachments, and should destroy all copies of them. This e-mail and any attachments may also contain copyright material belonging to Quillsoft Pty Ltd. The views expressed in this e-mail or attachments are the views of the author and not the views of Quillsoft Pty Ltd. You should only deal with the material contained in this e-mail if you are authorised to do so.

This notice should not be removed.

-- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe <email protected> For additional commands, e-mail: php-general-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>