huskies Posted November 2, 2011 Share Posted November 2, 2011 Sometimes if this while loop have to run for more than 2 minutes,the programs gets stuck. As in my next step never gets ran. but for regular situation (around 10 seconds, it runs perfectly), so do while loops in Autoit time out after a while? $file = fileopen($PuttyLogpath,0) Local $str = FileReadLine($file, -1) while $str <> $Message sleep(200) $str = FileReadLine($file, -1) WEnd <It Shall Be Done> Link to comment Share on other sites More sharing options...
Developers Jos Posted November 2, 2011 Developers Share Posted November 2, 2011 (edited) You need to test the success of filereadline and act on it in case of EOF. Edited November 2, 2011 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 2, 2011 Moderators Share Posted November 2, 2011 huskies, do while loops in Autoit time out after a while?No. By the way, I am none too sure that you will ever get out of your loop as you might be locking the file when you open it and so it can never be re-read. I found that this worked better: $Message = "End" $file = "test.txt" Local $str = FileReadLine($file, -1) While $str <> $Message Sleep(200) $str = FileReadLine($file, -1) ConsoleWrite($str & @CRLF) WEnd Any help? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Xandy Posted November 2, 2011 Share Posted November 2, 2011 (edited) $file = fileopen($PuttyLogpath, 0) Local $str = FileReadLine($file, -1) while $str <> $Message sleep(200) $str = FileReadLine($file, -1) if @error<> 0 then ExitLoop; tests for EOF WEnd ConsoleWrite(@CRLF&"program exited loop") Edited November 2, 2011 by songersoft Human Male Programmer (-_-) Xandy About (^o^) Discord - Xandy Programmer MapIt (Tile world editor, Image Tile Extractor, and Game Maker) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 2, 2011 Moderators Share Posted November 2, 2011 Guys,Why does he need to test for EOF? With the "line" parameter set to -1, the code is always reading the last line so there will never be an EOF return. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Xandy Posted November 2, 2011 Share Posted November 2, 2011 I did not know that, thanks M23. Human Male Programmer (-_-) Xandy About (^o^) Discord - Xandy Programmer MapIt (Tile world editor, Image Tile Extractor, and Game Maker) Link to comment Share on other sites More sharing options...
huskies Posted November 2, 2011 Author Share Posted November 2, 2011 thanks guys, im actually on the train right now so i will give it a shot when i get home. just a little context, what I am trying to do is run a query in a database with unix, and it will take between 5 seconds to 2 minutes, when the next command line is ready that means the query is done, then I will enter my next command here are some of my custom functions, I have Putty output the results in a txt file on my desktop so I can interact with it StartPutty($Puttypath, "db5") ReadLog($PuttyLogpath, "[company@db5.prod ~]$ ") sending("./generate_mtu_data.sh apps") //this is the query that will take 2 minutes to run ReadLog($PuttyLogpath, "[company@db5.prod ~]$ ") blah blah <It Shall Be Done> Link to comment Share on other sites More sharing options...
czardas Posted November 2, 2011 Share Posted November 2, 2011 (edited) I presume the file will be written to at some point, otherwise the last line may never equal $Message, and you will still be stuck in an infinite loop. You may want to add a time out option anyway to prevent that from happening. Edited November 2, 2011 by czardas operator64 ArrayWorkshop 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