Jump to content

readfile issues


Recommended Posts

I am trying to have the script read an existing file, and if it finds the string (status) = 0 then display a msg, if it does not find that string, display another msg. This string is always on the last lane, so if you know a way to look at the last line only, that would be great. I have been searching the whole file. Here's my code. PS, I am a total newbee.

;Variables
$Computername = EnvGet("computername")
$Welcome = 0
;$StorageServers = $CMDLineRaw
$StorageServers = "server"
$logfile = "C:\" & $Computername & ".log"

FileOpen ($logfile,0)

;Check if file opened for reading OK
If $logfile = -1 Then
    MsgBox (0, "Error", "Unable to open log file.")
    Exit
EndIf

While 1
    $line = FileReadLine($logfile)
    If @error = -1 Then ExitLoop
   if StringInStr($line, "(status)") > 0 Then
      $var = StringRight($line, 1)
   EndIf

WEnd

If $var = "0" Then
    MsgBox(0, "Process", "sucessfully captured.", 10)
Else
    MsgBox (0, "Process", "data migration CAN NOT BE CONFIRMED, please check C:\" & $Computername & ".log for errors during the process.")
    EndIf

FileClose($logfile)
Edited by frankpintosr
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...