Jump to content

[SOLVED] Regex in 7 Zip Std Out (and error)


 Share

Recommended Posts

Perhaps someone would benefit off this.  I made heavy use of the Help file example.

Only question I have here, is is there a better way to do the Regex for finding "error|ERROR|Error" in the source string?  Thx

Example7zPwd()

Func Example7zPwd()
    ;-- Local $iPID = Run(@ComSpec & " /c DIR Example.au3", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
    Local $iPID = Run(@ComSpec & " /c 7za t -pmasale myzip.zip ", "c:\files\testing", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
    Local $sOutput = ""
    Local $myError = 0
    ConsoleWrite("$myError:" & $myError & @CRLF)

    While 1
        $sOutput = StdoutRead($iPID)
        If @error Then ; Exit the loop if the process closes or StdoutRead returns an error.
            ExitLoop
        EndIf
        MsgBox($MB_SYSTEMMODAL, "Stdout Read:", $sOutput, 5)


        If StringRegExp($sOutput, '\b(error|ERROR|[Ee]rror)\b', 0) Then $myError = $myError + 1
        ;ConsoleWrite("$sOutput: " & $sOutput & @CRLF)
        ConsoleWrite("$myError: " & $myError & @CRLF)


    WEnd

    While 1
        $sOutput = StderrRead($iPID)
        If @error Then ; Exit the loop if the process closes or StderrRead returns an error.
            ExitLoop
        EndIf

        MsgBox($MB_SYSTEMMODAL, "Stderr Read:", $sOutput, 15)


    WEnd

    ConsoleWrite("$myError: " & $myError & @CRLF)

    If $myError > 0 Then
        MsgBox(64, "An Error Occurred", "The upgrade may be incomplete. An error occurred")
    EndIf

If StringRegExp($sOutput, '\b(error|ERROR|[Ee]rror)\b', 0) Then Is the Regex here optimized?

 

 

Edited by Skysnake

Skysnake

Why is the snake in the sky?

Link to comment
Share on other sites

I think http://www.regexr.com  do not support the (?i) but you need to add the flag /i in the Flags menu

Did you try the AutoIt code I posted ?

You can also use this website : https://regex101.com/r/wY9aR2/1

 

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

×
×
  • Create New...