Support Forums

Welcome to Support Forums Sign in | Join | Help
in
Home Forums

PSRead() Example

Last post 09-18-2006, 11:53 AM by Chris. 0 replies.
Sort Posts: Previous
  • PSRead() Example

     09-18-2006, 11:53 AM

    Hi All,

    The example given for PSRead() in the ProScript documentation lacks a useful program. Here is a script that will read each line of a file one-by-one until the EOF is reached. I tested on the boot.ini of a local disk. Just add the disk or image to a project, highlight the file in ProDiscovers content view, then right-click and choose run ProScript. The parameters will be auto-filled, then choose the script and run.

    ---------PSRead() Example----------------

    use ProScript;

    $TotalArg = @ARGV;

    if ($TotalArg != 1)

    {

          PSDisplayText("Usage: script_name <FILE_NAME>");

          exit;

    }

          $handle = PSOpen($ARGV[0]);

          if ($handle == 0)

          {

                PSDisplayText ("Unable to find $ARGV[0]");

                exit;

           }

    while(!PSIsEOF($handle))

    {

          $buffer = &ProScript::PSRead($handle);

          PSDisplayText("Contents: $buffer");

    }

    PSClose($handle);

    ------------- End Example -------------------

View as RSS news feed in XML