Nunos Posted December 12, 2017 Author Share Posted December 12, 2017 (edited) 36 minutes ago, jdelaney said: This might be easier: run(@ComSpec & ' /c sqlcmd -Lc > output.txt') Then just _filereadtoarray the output.txt. I don't recall if sqlcmd eats the pipe, but if it does, there is another parameter you can add to output to a file. I think the array is being created just not doing the pattern match properly for some reason. I can try to get it into a txt file then an array but I still need to search it for each Server Instance and Database Instance to get it into a gui so the end user can choose which matched pair is associated with their system. I think my problem lies in the $spattern = "\h+([\w\\-]+)"Local $aArray = StringRegExp($sOutput, $spattern,3) portion of the script but I am struggling to understand what I need to change to get a match on the $spattern I have tried several variations but I don't seem to be landing on what I need. I think the "-" in the naming convention for the server instances might be causing part of the problem but I am unsure. Edited December 12, 2017 by Nunos Link to comment Share on other sites More sharing options...
kylomas Posted December 12, 2017 Share Posted December 12, 2017 (edited) nunos, If you can post a file just as jdelaney advised we can provide better help... kylomas edit: Why do you need an array? Edited December 12, 2017 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Nunos Posted December 12, 2017 Author Share Posted December 12, 2017 (edited) #RequireAdmin run(@ComSpec & ' /c sqlcmd -Lc > C:\output.txt') output.txt Edited December 12, 2017 by Nunos Attached File of the output Link to comment Share on other sites More sharing options...
kylomas Posted December 13, 2017 Share Posted December 13, 2017 Nunos, That is only (local) DW-MWS DW-MWS\DINERWARE What do you want in the combo box(s)? kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Nunos Posted December 13, 2017 Author Share Posted December 13, 2017 The last line DW-MWS\Dinerware However on some locations that list might have 5 comboniations like below so I just need to make sure that they are matched up properly. DW-MWS DW-MWS\Dinerware MD-MWS\Dinerware001 WS01\Dinerware MDSRV\DINERWARE01 So I was thinking that the only thing that should always appear is the backslash between the ServerInstance and the actual Database Name. At one point I had it getting them but on ones that have a hyphen in the name it was not gathering the hyphen and characters left of it. Link to comment Share on other sites More sharing options...
kylomas Posted December 13, 2017 Share Posted December 13, 2017 (edited) Nunos, Try this, not sure if it is where you are going... expandcollapse popup#include <Array.au3> #include <GUIConstantsEx.au3> #include <GuiComboBox.au3> Local $str = FileRead(@ScriptDir & '\output.txt') ConsoleWrite($str & @CRLF) ;$spattern = '\h+([\w\\-]+)' $spattern = '(?m)^.*\\.*$' Local $array = StringRegExp($str, $spattern, 3) ;_arraydisplay($array) ; to populate a combo box from the array do... Local $gui010 = GUICreate('CB Example') GUICtrlCreateLabel('Node', 20, 20, 100, 20) Local $cmb010 = GUICtrlCreateCombo('', 20, 40, 150, 300) GUICtrlCreateLabel('DB', 220, 20, 100, 20) Local $cmb020 = GUICtrlCreateCombo('', 220, 40, 150, 300) ; populate combo boxes For $1 = 0 To UBound($array) - 1 GUICtrlSetData($cmb010, StringRegExpReplace($array[$1], '([^\\]+).*', '$1')) GUICtrlSetData($cmb020, StringRegExpReplace($array[$1], '[^\\]+\\(.*)', '$1')) Next ; set entry 0 as current (default) selection _GUICtrlComboBox_SetCurSel($cmb010, 0) _GUICtrlComboBox_SetCurSel($cmb020, 0) Local $btn010 = GUICtrlCreateButton('My Freak"in Button', 20, 360, 360, 20) GUICtrlSetState($btn010, $gui_focus) GUISetState() While 1 Switch GUIGetMsg() Case $gui_event_close Exit Case $btn010 MsgBox(0, '', GUICtrlRead($cmb010)) EndSwitch WEnd kylomas edit: corrected sre pattern edit2: File used for example output.txt Edited December 13, 2017 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Nunos Posted December 13, 2017 Author Share Posted December 13, 2017 I will run that tomorrow morning when I get to work on a couple test boxes to see what it does. Thank you for the help. Link to comment Share on other sites More sharing options...
Nunos Posted December 15, 2017 Author Share Posted December 15, 2017 I think it is working right. I was able to test it on the machine I collected the output.txt file from and the data appears proper. I will test more this week as I hope to have a couple new boxes in over the next few days. Thank you for the help I really appreciate it. Link to comment Share on other sites More sharing options...
TheDcoder Posted December 15, 2017 Share Posted December 15, 2017 Sorry for the late appearance, but have you tried using Run with StdoutRead? You can also use my Process UDF which should make things simple by consolidating all into a single line: Local $sOutput = _Process_RunCommand($PROCESS_RUNWAIT, @ComSpec & ' /c sqlcmd -Lc) ; $sOutput should contain the complete output of the `sqlcmd -Lc` command. _Process_RunCommand runs an executable and captures it output and returns it to $sOutput EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
jdelaney Posted December 15, 2017 Share Posted December 15, 2017 After the _filereadtoarry, delete the first element: _arraydelete($a,0)...good to go. IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now