SpecialK Posted January 17, 2007 Share Posted January 17, 2007 (edited) Hello, i've already made some scripts with AutoIT 3 and they work fine. But i never needed to read in some lines from a text or an ini file. Now i need this but i don't have an idea how to realize it. Here is a textfile for example: Server1 Server2 Server3 How can i get each line to a variable? For example: $line1 $line2 $line3 Thank you for your help. SpecialK Edited January 17, 2007 by SpecialK Link to comment Share on other sites More sharing options...
Edgar Posted January 17, 2007 Share Posted January 17, 2007 You can try the "_FileReadToArray" function as below. The code from help file : #include <file.au3> Dim $aRecords If Not _FileReadToArray("error.log",$aRecords) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf For $x = 1 to $aRecords[0] Msgbox(0,'Record:' & $x, $aRecords[$x]) Next Link to comment Share on other sites More sharing options...
SpecialK Posted January 17, 2007 Author Share Posted January 17, 2007 You can try the "_FileReadToArray" function as below. The code from help file : #include <file.au3> Dim $aRecords If Not _FileReadToArray("error.log",$aRecords) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf For $x = 1 to $aRecords[0] Msgbox(0,'Record:' & $x, $aRecords[$x]) Next oÝ÷ Ûú®¢×©äÊ£·ö÷¬¢[Þvl©®åzl"¶®¢Ò'u'¶*'ªê-"²¦ºé¬Â+aºw^®ËZاªëk+ºÙèÂØ^IÊâ¦Ü(®Kw^jëh×6 $var = IniReadSection ("test.ini", "Server") If @error Then MsgBox(4096, "", "INI Datei nicht gefunden") Else $notbremse= msgbox (17, "Server herunterfahren", "Achtung. Diese Datei fährt diverse Server herunter.", 10) if $notbremse = 2 Then Exit For $i = 1 To $var[0][0] Run ("shutdown.exe -m \\" & $var[$i][1] & " -s -t 10 -f") Next Sleep (60000) For $i = 1 To $var[0][0] Ping ( $var[$i][1] , 250) if @error = 0 Then msgbox (0, "Noch online", "Server " & $var[$i][1] & " ist noch online." & @CRLF & "Sende erneut Shutdown Befehl.", 10) Run ("shutdown.exe -m \\" & $var[$i][1] & " -s -t 10 -f") EndIf Next EndIf 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