17 posts in this topic
By Kevin Finnegan
Long time lurker and now forum poster! I'm writing a relatively simple backup script for my firm that automates the copy, compression and organization of Leaver's data on one of our secured NAS systems. I personally found the best method to do this so far was to use 7zG.exe (GUI version of 7Zip which can use command-line too) and it functions quite well!
I would like to retrieve more info on whether any warnings or errors happen in 7Zip during the backup, but I can't quite get my head around the syntax and switches for reading out, it seems any adjustment I make to the RunWait call's string seems to break the backup or give unexpected repercussions! Hopefully its something silly I'm doing as I don't code very often.
Here is the working version:
; Compress the directories one by one in the zip using the listfile.... Local $iPID = RunWait(@ScriptDir & "\bin\7zG.exe a -mx" & $compressionQuality & " -v" & $compressSplitFileSize & " -wc:\temp " _ & $backupToLocation & "\" & $userDirectory & ".7z @bin\listfile.txt -x@bin\excludefile.txt", "", @SW_SHOWDEFAULT, $STDOUT_CHILD) Ultimately I would love to switch entirely to 7za.exe (standalone) so that I can read the progress percentage, current file being uploaded and any warnings or errors could be processed and output to the AutoIT script's GUI I've created rather than jumping in and out of two applications per se.
I got a UDF to zip the files from below link.
With this I am able to create a zip file but the post processing of zip file creation I am checking the zip file exists or not, but it is giving the message as file not found.
#include "Zip.au3" ZipLogs() Func ZipLogs() $ResultsFolder = @ScriptDir & "\Results" $ResultsDestFolder = @ScriptDir & "\Results_Archive" $zipFile = $ResultsDestFolder & "\Results_"&TodayDateTime()&".zip" DirCreate($ResultsDestFolder) Dim $Zip = _Zip_Create($zipFile) ;Create The Zip File. Returns a Handle to the zip File _Zip_AddFolderContents($Zip, $ResultsFolder) ;Add a folder's content in the zip file if FileExists(@ScriptDir&"\Logging.log") then _Zip_AddFile($Zip,@ScriptDir&"\Logging.log") FileDelete(@ScriptDir&"\Logging.log") EndIf if FileExists(@ScriptDir&"\RemoteExecution_Log.txt") then _Zip_AddFile($Zip,@ScriptDir&"\RemoteExecution_Log.txt") FileDelete(@ScriptDir&"\RemoteExecution_Log.txt") EndIf if FileExists($zipFile) then DirRemove($ResultsFolder,$DIR_REMOVE) Else MsgBox(0,"","Zip file not found") EndIf return $zipFile EndFunc
There is a build machine in the network where it will automatically download the code from source repository and compile using visual studio and compresses the complete code in a zip file.
I have added a line at the end of the build script(written in python on that machine) to copy that zip file to my ESX Virtual machine.
Where I kept a AutoIT exe to wait for the zip file, once it is copied then I will extract the contents and find only the dll files in the extracted folder and do the Install creation using Installshield silently and copy the created setup files to anther machine.
I wrote the script till the setup files creation.
But now the problem is, when the zip file is copying through network, the autoit script is detecting it even the copy is still in progress and trying to extract the zip file and failing.
Even when I am checking whether the file in use is not working.
Any suggestion on how to check whether the copy is completed.?
i hope i am in the right place for this question as it is in regards to zip.au3.
I have some encrypted files on my harddrive which zip.au3 can't open. This is perfectly fine. The Problem is that it crashes my program as soon as it tries to access the file.
Is there a way to detect if the file is encrypted BEFORE autoit tries to open it? I am using _zip_unzipall to unzip the file, i also tried _zip_count with the same result. My files are encrypted with SafeGuard Lan Crypt.
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?