blemas Posted February 27, 2017 Posted February 27, 2017 The McAfee return for AV defs per "C:\Progra~1\Common~1\McAfee\SystemCore\csscan.exe -Versions" is ... CommonShell Command Line Scanner Lite (VSCORE.15.5.0.3960) Engine version: 5800.7501 DAT version: 8450.0 Time required: 15 milliseconds I want to isolate the actual DAT version as "8450.0". There may be an easier way to get the DAT Version via other McAfee or registry methods but essentially I just want to know how to parse a string at a character or @CRLF into two separate strings for further parsing. Example: $string = "Name=Microsoft Windows 10 Professional |C:\windows|\Device\Harddisk0\Partition2" Parse into $var1 = "Name" & $var2 = "Microsoft Windows 10 Professional |C:\windows|\Device\Harddisk0\Partition2" From there I'd like to parse $var2 at "|" into $var3 = "Microsoft Windows 10 Professional" and $var4 "C:\windows|\Device\Harddisk0\Partition2"
water Posted February 27, 2017 Posted February 27, 2017 Welcom to AutoIt and the forum! Use something like this: $string = "Name=Microsoft Windows 10 Professional |C:\windows|\Device\Harddisk0\Partition2" $aResult1 = StringSplit($string, "=") $aResult2 = StringSplit($aResult1[2], "|") You get two arrays with the resulting substrings. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
blemas Posted February 28, 2017 Author Posted February 28, 2017 Thanks for the help. That looks like it would work but I'm getting no results (pebkac?). $string = "Name=Microsoft Windows 10 Professional |C:\windows|\Device\Harddisk0\Partition2" $aResult1 = StringSplit($string, "=") $aResult2 = StringSplit($aResult1[2], "|") MsgBox(0, "aResult1", "" & $aResult1, 1.5) MsgBox(0, "aResult2", "" & $aResult2, 1.5) What am I missing?
Moderators JLogan3o13 Posted February 28, 2017 Moderators Posted February 28, 2017 Moved to General Help and Support, as the Examples forum clearly states: Quote Do not post general support questions here, instead use the AutoIt Help and Support forums. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Subz Posted February 28, 2017 Posted February 28, 2017 (edited) It's an array not a string, so use _ArrayDisplay in place of MsgBox _ArrayDisplay($aResult1) _ArrayDisplay($aResult2) Edited February 28, 2017 by Subz
blemas Posted February 28, 2017 Author Posted February 28, 2017 Got it... #include <Constants.au3> Global $DOS, $Message = '' ;; added "= ''" for show only. $DOS = Run(@ComSpec & " /c C:\Progra~1\Common~1\McAfee\SystemCore\csscan.exe -Versions", "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) ProcessWaitClose($DOS) $local_av_version = StdoutRead($DOS) MsgBox(65536, "", "The McAfee AV information" & @CRLF & $local_av_version) Dim $split[3] Global $split = StringSplit($local_av_version, ":") $1 = $split[1] $2 = $split[2] $variable = $split[3] Dim $sourcetwo[2] $sourcetwo = StringSplit($variable, "Time") $DAT_Version = $sourcetwo[1] $b = $sourcetwo[2] $DAT_Ver = StringStripWS($DAT_Version,$STR_STRIPALL) MsgBox(0, 'The McAfee DAT Version is....', "Results = " & $DAT_Ver)
Subz Posted February 28, 2017 Posted February 28, 2017 You could also do it like so: $sString = "" $sString &= "CommonShell Command Line Scanner Lite (VSCORE.15.5.0.3960)" & @LF $sString &= " Engine version: 5800.7501" & @LF $sString &= " DAT version: 8450.0" & @LF $sString &= " Time required: 15 milliseconds" & @LF $aString = StringSplit($sString, @LF) For $i = 1 To $aString[0] If StringInStr($aString[$i], "DAT Version:") Then $sDATVersion = StringStripWS(StringReplace($aString[$i], "DAT Version:", ""), 8) Next ConsoleWrite($sDATVersion & @CRLF) blemas and spoo 2
blemas Posted February 28, 2017 Author Posted February 28, 2017 That's a great piece of code, I may end up using it. Thanks!
blemas Posted February 28, 2017 Author Posted February 28, 2017 Much cleaner. I'm going with this....
blemas Posted February 28, 2017 Author Posted February 28, 2017 #include <Constants.au3> Global $DOS, $Message = '' $DOS = Run(@ComSpec & " /c C:\Progra~1\Common~1\McAfee\SystemCore\csscan.exe -Versions", "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) ProcessWaitClose($DOS) $sString = StdoutRead($DOS) $aString = StringSplit($sString, @LF) For $i = 1 To $aString[0] If StringInStr($aString[$i], "DAT Version:") Then $sDATVersion = StringStripWS(StringReplace($aString[$i], "DAT Version:", ""), 8) Next MsgBox(0,"", "DATVersion=" & $sDATVersion & @CRLF)
gruntydatsun Posted March 1, 2017 Posted March 1, 2017 #include <Array.au3> $string = "Name=Microsoft Windows 10 Professional |C:\windows|\Device\Harddisk0\Partition2" $array1 = StringSplit($string,"=,|",2) _ArrayDisplay($array1)
water Posted March 1, 2017 Posted March 1, 2017 What is the "," for in your example? There is no "," in the example data to split at My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
gruntydatsun Posted March 1, 2017 Posted March 1, 2017 or #include <Array.au3> $sString = " Engine version: 5800.7501" & @LF $sString &= " DAT version: 8450.0" & @LF $sString &= " Time required: 15 milliseconds" & @LF $array1 = StringRegExp($sString,"DAT version:\s*(\d+\.?\d*)",1) _ArrayDisplay($array1) the regex reads: "DAT version" then zero or more spaces then one or more digits then zero or one fullstop then zero or more digits
gruntydatsun Posted March 1, 2017 Posted March 1, 2017 hi water, that comma slipped past me .... it's the end of the day here and i'm pooped
water Posted March 1, 2017 Posted March 1, 2017 I see. Good night My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
mikell Posted March 1, 2017 Posted March 1, 2017 Msgbox(0,"", StringRegExpReplace($sString, "(?s).*DAT version:\s*(\S+).*", "$1") )
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