Jump to content

Xulong

Members
  • Posts

    15
  • Joined

  • Last visited

Xulong's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. Thank you for the script. Now I know the _FileListToArrayRec which is way more tidy and nice to use in this case. I am going to see how to fix the CC.Net issue now.
  2. So the problem I have at the moment is the script I have post initially is working now (script not hanging after FileCopy) but when integrated with CCNet, the script is running for a few minutes and did not copy the file over (only takes 9 seconds if execute manually)
  3. Here is the Array (I trimed a bit as the full list is too long) From ConsoleWrite, the results is: But the file didn't be copied over to Destination.
  4. @Subz after executing the above script, I got below message back:
  5. I used MSGBOX which gives me the correct path but when I use the above ConsoleWrite it gives me error incorrect parameters. So I tried my script again and it now returns the exit code straight after the FileCopy. But it hangs again when I use the script with CruiseControl as an executable task.
  6. @Subz Thanks for the script. It seems not copying file.
  7. It is hanging before the _filewritelog.
  8. The file is not large only under 100MB, I can see the file being successfully copied over using the script but just the script won't return exit code after successfully copied over and hanging there for a few minutes before it returns the exit code.
  9. I have a script which is copying one file (the latest file among a bunch of structured folders) from one network device to another network device. The weird thing is the file copied successfully to the destination folder right after the FileCopy command ran but the script is hanging for another few minutes until it return with exit code 0. Below is my script: #include <MsgBoxConstants.au3> #include <File.au3> #include <Array.au3> #include <FileConstants.au3> copyfile() Func copyfile() Local $testLogFile = FileOpen(@ScriptDir & "\CopyMSI", 1) Local $BuildArtifacts = "\\vm-build\BuildArtifacts" Local $dServer = "\\VM-DEV\c$\Users\Administrator\Desktop" Send("#r") WinWaitActive("Run") ControlSend("Run", "", 1001, $BuildArtifacts) ControlClick("Run", "OK", 1) _FileWriteLog($testLogFile, "Opened Builds folder") ;trying to get the latest build folder and grab the latest msi file for copying WinWaitActive("BuildArtifacts") Local $FolderList = _FileListToArray($BuildArtifacts, "Grand-4.*") _ArraySort($FolderList, 1) Local $latestSEbuild = $FolderList[0] Sleep (5000) WinClose("BuildArtifacts") Local $sServer = $BuildArtifacts & '\' & $latestSEbuild & '\G4.msi' ; start copying file from build to destination folder FileCopy($sServer, $dServer, $FC_OVERWRITE) _FileWriteLog($testLogFile, "Copied MSI") EndFunc
  10. Thank you Jimwright, The ACTUAL meat is probably what I am looking for.
  11. Thanks for your reply JohnOne. I think short answer is No. The reason is the CI tool has to be able to execute the script locally not remotely. And the application event log I want to check is sit on another server. Is there a way I can achieve that? I know I can probably backup the event log file with that specific source and error/critical/warning filter, but how can I copy that across to the destination (CI server) and to validate the file there? Thanks.
  12. I am trying to create a script to allow our continues integration tool to pickup the output (1 or 0 for example) after read the event log for a specific application and looking for critical, error and warning, the application is running on a different server from which the script will be running. How can I achieve that? Thank you in advance.
  13. Hi r3dbullo88, I figured out, actually, I was too focused on 0 being failed and 1 being success, alternatively, I can change the value I used in Cruise Control to take 1 as failed and 0 as success. Thanks for your help.
  14. Thanks for your help r3dbullo88. That's great, I can get a return value now. But the value returned here is 1 because the script works fine but I want 0 returned if I find a specific string in the test file (i.e., here is " 0"), and not about the script being ran is failed or pass. (I recorded 0 or 1 for test fail and pass while executing those sql script). As I need a value returned by AutoIT which I can use in the next step to fail a build process in Cruise Control. Below is my current script with your function, return, end function. #include <File.au3> #include <FileConstants.au3> #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> SQL_Test_Check() Func SQL_Test_Check() ; File path for msi Local $filepath = "C:\sqlbatch.bat" Local $verifile = "C:\Temp\sqlresults.txt" Local $check ;Create a write log file Local $SQLAutomationLog = FileOpen (@ScriptDir & "\Temp\SQLAutomationLog", 1) ; check msi is there or not If FileExists ($filepath) Then _FileWriteLog($SQLAutomationLog, "sqlbatch has been found") Else _FileWriteLog($SQLAutomationLog, "sqlbatch has not been found, please ensure you have sqlbatch under your testing environment") EndIf ; run bat file Local $batch = Run ("C:\sqlbatch.bat") ProcessWait ($batch) Sleep (20000) _FileWriteLog($SQLAutomationLog, "sqlbatch.bat file found and starting") ; check sqlresults file is there or not If FileExists ($verifile) Then _FileWriteLog($SQLAutomationLog, "sqlresults file has been found") Else _FileWriteLog($SQLAutomationLog, "sqlresults file has not been found, please ensure the sqlbatch.bat has been run correctly") EndIf ; red the sqlresults file $file = FileOpen($verifile, 0) $read = FileRead($file) If @error = -1 Then _FileWriteLog($SQLAutomationLog, "error reading sqlresults file") Exit Else _FileWriteLog($SQLAutomationLog, $read) $check = StringRegExp($read, " 0") If $check Then _FileWriteLog($SQLAutomationLog, "Failed, there is failed SQL test") Else _FileWriteLog($SQLAutomationLog, "Passed, all SQL tests are passed") EndIf EndIf FileClose($file) Return $check EndFunc ;debug use, check the returned value ;MsgBox(64,"The return value","The return value from SQL_Test_Check function is: " & SQL_Test_Check()) ; delete the sqlresults log file ;FileDelete ("C:\Temp\sqlresults.txt")
  15. So I am trying to return a value (0 or 1) for failed or passed after file read located a specific things I am looking for is there or not. Below is part of my script and is related to the file read function (currently I used the msgbox, which I want it return a value and exit the function and the returned value will be used by Cruise Control). So if the " 0" is presented in the file I am reading, then return a value of 0, otherwise return a 1. And if the result is 0 then return that 0 value, which this value will be used to check against in our cruise control success exit code, i.e., our success exit code is 1, the value returned by autoIT after file read is 0, then the build will be failed. Hope this is clear. and thanks for your help. $file = FileOpen($verifile, 0) $read = FileRead($file) If @error = -1 Then _FileWriteLog($SQLAutomationLog, "error reading sqlresults file") Exit Else _FileWriteLog($SQLAutomationLog, $read) If StringRegExp($read, " 0") Then MsgBox(0, "Failed", "There is failed SQL test") Else MsgBox(0, "Passed", "All SQL tests are passed") EndIf EndIf FileClose($file)
×
×
  • Create New...