Kovitt Posted July 2, 2008 Share Posted July 2, 2008 (edited) Ok, So I understand the basics of it, but I need to make a stringregExp to find "RUNNING" or "STOPPED" or "PAUSED" from: SERVICE_NAME: FTP to Inbox TYPE : 10 WIN32_OWN_PROCESS STATE : 4 RUNNING (STOPPABLE,PAUSABLE,ACCEPTS_SHUTDOWN) WIN32_EXIT_CODE : 0 (0x0) SERVICE_EXIT_CODE : 0 (0x0) CHECKPOINT : 0x0 WAIT_HINT : 0x0 So what ever is after STATE : 4.. Can someone tell me how to do this and hopefully explain it? Thanks Edited July 9, 2008 by Kovitt Link to comment Share on other sites More sharing options...
GEOSoft Posted July 2, 2008 Share Posted July 2, 2008 (edited) Ok, So I understand the basics of it, but I need to make a stringregExp to find "RUNNING" or "STOPPED" or "PAUSED" from: SERVICE_NAME: FTP to Inbox TYPE : 10 WIN32_OWN_PROCESS STATE : 4 RUNNING (STOPPABLE,PAUSABLE,ACCEPTS_SHUTDOWN) WIN32_EXIT_CODE : 0 (0x0) SERVICE_EXIT_CODE : 0 (0x0) CHECKPOINT : 0x0 WAIT_HINT : 0x0 So what ever is after STATE : 4.. Can someone tell me how to do this and hopefully explain it? ThanksThis will get what I think you need. The reason I left the 4 in the string is because I'm reasonably sure that the number changes with different states. $srx = StringRegExp("STATE : 4 RUNNING", "(?i)[^STATE : ] .*", 1) $Out = $srx[0]Will return "4 RUNNING" Of course there is a _Service_GetState() function here http://dundats.mvps.org/AutoIt/udf_code.aspx?udf=services Edited July 2, 2008 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Xenobiologist Posted July 3, 2008 Share Posted July 3, 2008 This will get what I think you need. The reason I left the 4 in the string is because I'm reasonably sure that the number changes with different states. $srx = StringRegExp("STATE : 4 RUNNING", "(?i)[^STATE : ] .*", 1) $Out = $srx[0]Will return "4 RUNNING" Of course there is a _Service_GetState() function here http://dundats.mvps.org/AutoIt/udf_code.aspx?udf=services Hi, I would prefer using a neutral function. This regex pattern ist only valid on English PCs. Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
Kovitt Posted July 8, 2008 Author Share Posted July 8, 2008 Thanks for all the help! I have another quick one: The output is: CODE JOB ---------- WHAT -------------------------------------------------------------------------------- 289 dbms_refresh.refresh('"IFACT"."MV_BBS_CE_LST"'); 530 IFACT.Call_Rollup_Pkg.Call_Rollup_Proc(351, 10000); 529 IFACT.Call_Rollup_Pkg.Call_Rollup_Proc(1, 350); JOB ---------- WHAT -------------------------------------------------------------------------------- 221 dbms_refresh.refresh('"IFACT"."MV_SMS_BILL_UNIT"'); 141 IFACT.Call_Rollup_Pkg.Call_Rollup_Proc(10001, 51000); 533 IFACT.Call_Rollup_Pkg.Call_Rollup_Proc(55001, 60000); And I need to capture the number above each IFACT line, so for example from: 530 IFACT.Call_Rollup_Pkg.Call_Rollup_Proc(351, 10000); I need to capture 530 in its own array as well as 351 and 10000 in their own seperate arrays, they would be named $Jobs $RangeS $RangeE . . As you can see the ranges varry in length. Also I do not need the numbers above the dbms lines. Thanks for all the help guys!! P.S. (If anyone could explain to me how StringRegExp works, I wouldn't have to keep asking muttley The help file is quite vague.. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 8, 2008 Moderators Share Posted July 8, 2008 (edited) Thanks for all the help! I have another quick one: The output is: CODE JOB ---------- WHAT -------------------------------------------------------------------------------- 289 dbms_refresh.refresh('"IFACT"."MV_BBS_CE_LST"'); 530 IFACT.Call_Rollup_Pkg.Call_Rollup_Proc(351, 10000); 529 IFACT.Call_Rollup_Pkg.Call_Rollup_Proc(1, 350); JOB ---------- WHAT -------------------------------------------------------------------------------- 221 dbms_refresh.refresh('"IFACT"."MV_SMS_BILL_UNIT"'); 141 IFACT.Call_Rollup_Pkg.Call_Rollup_Proc(10001, 51000); 533 IFACT.Call_Rollup_Pkg.Call_Rollup_Proc(55001, 60000); And I need to capture the number above each IFACT line, so for example from: 530 IFACT.Call_Rollup_Pkg.Call_Rollup_Proc(351, 10000); I need to capture 530 in its own array as well as 351 and 10000 in their own seperate arrays, they would be named $Jobs $RangeS $RangeE . . As you can see the ranges varry in length. Also I do not need the numbers above the dbms lines. Thanks for all the help guys!! P.S. (If anyone could explain to me how StringRegExp works, I wouldn't have to keep asking muttley The help file is quite vague..And you tried??? No one can "just explain" how regexp works. It's up to you as the individual that wants to use it to figure it out. There are many tutorials on the net, read one (AutoIt uses the PCRE engine for its regular expressions). http://www.google.com/search?hl=en&cli...ial&spell=1 $a_sre = StringRegExp($s_text, "(?s)(\d+)\s*\r\nIFACT\.", 3) Edited July 8, 2008 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Kovitt Posted July 8, 2008 Author Share Posted July 8, 2008 (edited) And you tried??? No one can "just explain" how regexp works. It's up to you as the individual that wants to use it to figure it out. There are many tutorials on the net, read one (AutoIt uses the PCRE engine for its regular expressions). http://www.google.com/search?hl=en&cli...ial&spell=1 $a_sre = StringRegExp($s_text, "(?s)(\d+)\s*\r\nIFACT\.", 3)Thanks for the reply. I did give it a shot before asking.. What I came up with was StringRegExp($Jobs,'(?:'('{1})([0-9]{1,})(?:','{1})') StringRegExp($Jobs,'(?:','{1})([0-9]{1,})(?:')'{1})') For the Ranges.. They didn't work and As far as the job number goes I wasn't able to get it to get the ones that are above the IFACT lines only.. Thanks for your StringRegExp.. I will give it a shot. P.S. The tutorials you linked were quite helpful! Edit: Disabled Emoticons Edited July 8, 2008 by Kovitt Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 8, 2008 Moderators Share Posted July 8, 2008 Thanks for the reply. I did give it a shot before asking.. What I came up with was StringRegExp($Jobs,'(?muttley'{1})([0-9]{1,})(?:','{1})') StringRegExp($Jobs,'(?:','{1})([0-9]{1,})(?:')'{1})') For the Ranges.. They didn't work and As far as the job number goes I wasn't able to get it to get the ones that are above the IFACT lines only.. Thanks for your StringRegExp.. I will give it a shot. P.S. The tutorials you linked were quite helpful! Edit: Disabled EmoticonsYou couldn't even run those attempts through scite, they are syntactically incorrect, so you wouldn't even know if the expressions were right or wrong . Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Kovitt Posted July 8, 2008 Author Share Posted July 8, 2008 Unfortunatly the StringRegExp you Provided came up with no results You said earlier that : StringRegExp($Jobs,'(?:'('{1})([0-9]{1,})(?:','{1})',1) StringRegExp($Jobs,'(?:','{1})([0-9]{1,})(?:')'{1})',1) Were not syntactically correct.. What did I do wrong? I would like to know for future reference.. Thanks again for spending the time to help me out! Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 8, 2008 Moderators Share Posted July 8, 2008 Unfortunatly the StringRegExp you Provided came up with no results You said earlier that : StringRegExp($Jobs,'(?muttley'{1})([0-9]{1,})(?:','{1})',1) StringRegExp($Jobs,'(?:','{1})([0-9]{1,})(?:')'{1})',1) Were not syntactically correct.. What did I do wrong? I would like to know for future reference.. Thanks again for spending the time to help me out!1. I copied the data you provided, and used that as $s_text, and it worked fine (the regular expression). If the data is different, and you were trying to just provide a luke example, it doesn't plug and play like you want when doing that... you actually have to make the corrections yourself in that situation. 2. Copy the StringRegExp you have there into scite, you'll see the issues. When you concat strings, you must use an ampersand. But there is no need to concat here. "(?{1}) makes no sense, 1 what? Unless you are actually trying to find a parenthesis. "(?:\({1})(\d+)(?:,{1})" is roughly what I see from what you have up there. Note I don't have single quotes in there. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 8, 2008 Moderators Share Posted July 8, 2008 (edited) After seeing your example, I see that it isn't the text above IFACT you want, it the text in the parenthesis. This will only get the data from the parenthesis to the comma:#include <array.au3> $s_text = ClipGet() $a_sre = StringRegExp($s_text, "(?s)IFACT.+?\((\d+)\D", 3) _ArrayDisplay($a_sre) If you want both numbers in the parethesis it will look something like:#include <array.au3> $s_text = ClipGet() $a_sre = StringRegExp($s_text, "(?s)IFACT.+?\((\d+),\s*(\d+)\)", 3) _ArrayDisplay($a_sre) For $i = 0 To UBound($a_sre) - 1 Step 2 MsgBox(0, $i, "(" & $a_sre[$i] & ", " & $a_sre[$i + 1] & ")") Next Edited July 8, 2008 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
aslani Posted July 8, 2008 Share Posted July 8, 2008 $a_sre = StringRegExp($s_text, "(?s)(\d+)\s*\r\nIFACT\.", 3) Hi, can I ask a favor? You did this before so can you please do it again? Can you break it down and explain what's going on in that pattern? Thank you much. muttley P.S. I took your advice and still learning RegEx, an explanation here will help. [font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version Link to comment Share on other sites More sharing options...
Kovitt Posted July 9, 2008 Author Share Posted July 9, 2008 (edited) hello, So I tried the following with no luck: RunWait(@ComSpec & " /c echo select job, what from all_jobs; | sqlplus -s ****/*****@**** > Jobs.txt") $pathJ = FileOpen("Jobs.txt",0) While True $LineJ = FileReadLine($PathJ) If @error = -1 Then ExitLoop EndIf $a_sre = StringRegExp($LineJ, "(?i)[^IFACT.Call_Rollup_Pkg.Call_Rollup_Proc] .", 3) if @error = 0 Then $a_sreJ[$count] = $a_sre[0] EndIf WEnd _ArrayDisplay($a_sreJ) All it gave me was "1 row selected." Any Ideas why? Edited July 9, 2008 by Kovitt Link to comment Share on other sites More sharing options...
Kovitt Posted July 9, 2008 Author Share Posted July 9, 2008 muttley Link to comment Share on other sites More sharing options...
Kovitt Posted July 10, 2008 Author Share Posted July 10, 2008 I figured it out.. What I ended up using is modying the query so the output looks like: CODE JOB WHAT ----- ------------------------------------------------------------ 301 IFACT.TMP_OTPT_EXTRACT_PROC; 381 begin ogw_refresh_ogw_cgw_device; ogw_refresh_ogw_ts100_device; end; 289 dbms_refresh.refresh('"IFACT"."MV_BBS_CE_LST"'); 530 IFACT.Call_Rollup_Pkg.Call_Rollup_Proc(351, 10000); 529 IFACT.Call_Rollup_Pkg.Call_Rollup_Proc(1, 350); 221 dbms_refresh.refresh('"IFACT"."MV_SMS_BILL_UNIT"'); 141 IFACT.Call_Rollup_Pkg.Call_Rollup_Proc(10001, 51000); JOB WHAT ----- ------------------------------------------------------------ 533 IFACT.Call_Rollup_Pkg.Call_Rollup_Proc(55001, 60000); 532 IFACT.Call_Rollup_Pkg.Call_Rollup_Proc(51001, 55000); 241 IFACT.Call_Rollup_Pkg.Call_Rollup_Proc(60001, 65000); 281 IFACT.Call_Rollup_Pkg.Call_Rollup_Proc(65001, 999999999); 11 rows selected. I then used the following StringReg $pathJ = FileOpen("Jobs.txt",0) While True $LineJ = FileReadLine($PathJ) If @error = -1 Then ExitLoop EndIf $a_sre = StringRegExp($LineJ, "([0-9]{1,})(?:\s{1,})(?:IFACT.Call_Rollup_Pkg.Call_Rollup_Proc\W)([0-9]{1,})(?:, )([0-9]{1,})", 3) if @error = 0 Then $Job[$count] = $a_sre[0] $RangeS[$count] = $a_sre[1] $RangeE[$count] = $a_sre[2] EndIf $count = $count + 1 WEnd Again thanks for everyones help! muttley Link to comment Share on other sites More sharing options...
GEOSoft Posted July 10, 2008 Share Posted July 10, 2008 I figured it out.. What I ended up using is modying the query so the output looks like: CODE JOB WHAT ----- ------------------------------------------------------------ 301 IFACT.TMP_OTPT_EXTRACT_PROC; 381 begin ogw_refresh_ogw_cgw_device; ogw_refresh_ogw_ts100_device; end; 289 dbms_refresh.refresh('"IFACT"."MV_BBS_CE_LST"'); 530 IFACT.Call_Rollup_Pkg.Call_Rollup_Proc(351, 10000); 529 IFACT.Call_Rollup_Pkg.Call_Rollup_Proc(1, 350); 221 dbms_refresh.refresh('"IFACT"."MV_SMS_BILL_UNIT"'); 141 IFACT.Call_Rollup_Pkg.Call_Rollup_Proc(10001, 51000); JOB WHAT ----- ------------------------------------------------------------ 533 IFACT.Call_Rollup_Pkg.Call_Rollup_Proc(55001, 60000); 532 IFACT.Call_Rollup_Pkg.Call_Rollup_Proc(51001, 55000); 241 IFACT.Call_Rollup_Pkg.Call_Rollup_Proc(60001, 65000); 281 IFACT.Call_Rollup_Pkg.Call_Rollup_Proc(65001, 999999999); 11 rows selected. I then used the following StringReg $pathJ = FileOpen("Jobs.txt",0) While True $LineJ = FileReadLine($PathJ) If @error = -1 Then ExitLoop EndIf $a_sre = StringRegExp($LineJ, "([0-9]{1,})(?:\s{1,})(?:IFACT.Call_Rollup_Pkg.Call_Rollup_Proc\W)([0-9]{1,})(?:, )([0-9]{1,})", 3) if @error = 0 Then $Job[$count] = $a_sre[0] $RangeS[$count] = $a_sre[1] $RangeE[$count] = $a_sre[2] EndIf $count = $count + 1 WEnd Again thanks for everyones help! muttleyIt's good that you have it working but you can speed it up by not using FileReadLine(). Read the file to an array with _FileReadToArray() instead and then loop through the array using your RegEx. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Kovitt Posted July 10, 2008 Author Share Posted July 10, 2008 It's good that you have it working but you can speed it up by not using FileReadLine(). Read the file to an array with _FileReadToArray() instead and then loop through the array using your RegEx.I tried that and my array kept coming up empty, so I just went to filereadline. Im sure I was doing something wrong Link to comment Share on other sites More sharing options...
aslani Posted July 10, 2008 Share Posted July 10, 2008 It's good that you have it working but you can speed it up by not using FileReadLine(). Read the file to an array with _FileReadToArray() instead and then loop through the array using your RegEx.There's a weird thing going on with _FileReadToArray(). If I cut something from a post in this forum, paste it on Notepad and save it as .txt file, _FileReadToArray() comes out empty. But if I typed the same thing manually, _FileReadToArray() comes up with a full array.I wonder what's going on. [font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version Link to comment Share on other sites More sharing options...
GEOSoft Posted July 10, 2008 Share Posted July 10, 2008 There's a weird thing going on with _FileReadToArray(). If I cut something from a post in this forum, paste it on Notepad and save it as .txt file, _FileReadToArray() comes out empty. But if I typed the same thing manually, _FileReadToArray() comes up with a full array.I wonder what's going on.An actual example would help. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
aslani Posted July 10, 2008 Share Posted July 10, 2008 (edited) An actual example would help. I can't seem to find the post but I still have the text file. EDIT: Also this is the code I used to test it and it comes blank. #include <File.au3> #include <Array.au3> $file = @DesktopDir & "\ip.txt" Dim $aIP _FileReadToArray($file, $aIP) _ArrayDisplay($aIP, "IP List")ip.txt Edited July 10, 2008 by aslani [font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version Link to comment Share on other sites More sharing options...
Kovitt Posted July 10, 2008 Author Share Posted July 10, 2008 I can't seem to find the post but I still have the text file. EDIT: Also this is the code I used to test it and it comes blank. #include <File.au3> #include <Array.au3> $file = @DesktopDir & "\ip.txt" Dim $aIP _FileReadToArray($file, $aIP) _ArrayDisplay($aIP, "IP List")I have ran into small glitches like that, for example in my stringreg, where I have that IFACT.... part, I copied that from my output file, and it didnt work, So I then Typed the EXACT same thing in, and it worked ... muttley 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