CHOVIE 1 Posted July 15, 2013 Share Posted July 15, 2013 Good Day All, Please have a look at the below partial script that I have created, I have done this script before but lost all my back ups and HDD`s ..... I have gone through all the help files and forums to see why this is not working and could not find anything ... (maybe I am just stupid and can`t read) ... once the script is running and you click on one of the buttons to execute the below command it just runs in a loop and carries on and on until you pause the script. This command basically needs to go to a specific file take the IP from there open a telnet session and execute the commands required. Do I need to #include anything? Thank you for having a look ........ Case $PE $sfileSpec = "C:\CCTV\Allsvr\PESVR.ini" $file = FileOpen($sfileSpec, 0) If $file = -1 Then MsgBox(0, "Error", "Unable to open data file: '" & $sFileSpec & "'") Exit EndIf While 5 $sLine = FileReadLine($file) If @error = -1 Then ExitLoop $sWindowTitle = "Telnet" & $sLine $result = Run(@ComSpec & " /c telnet " & $sline) if $result <> 0 Then Sleep(500) WinActivate($sWindowTitle) Sleep(200) Send("e") Sleep(300) Send("{ENTER}") Sleep(300) Send("*r?") Sleep(300) Send("{ENTER}") Sleep(300) Else MsgBox(0, "Error", "Failed to run Telnet for server '" & $sLine & "'!") EndIf WEnd CHOVIE ..... To Be The Best You Have To Beat The Best ..... Link to post Share on other sites
Bert 1,520 Posted July 15, 2013 Share Posted July 15, 2013 Read up on Case and see how it is properly used. It looks to me you have that part of your script coded incorrectly. http://www.autoitscript.com/autoit3/docs/keywords/Select.htm The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to post Share on other sites
orbs 206 Posted July 15, 2013 Share Posted July 15, 2013 that said - ignoring syntax and horrific indentation - your script works fine. this is after some minor modifications, and i placed an IP address in the .ini file. $sfileSpec = "D:\PESVR.ini" $file = FileOpen($sfileSpec, 0) If $file = -1 Then MsgBox(0, "Error", "Unable to open data file: '" & $sFileSpec & "'") Exit EndIf While 5 $sLine = FileReadLine($file) If @error = -1 Then ExitLoop $sWindowTitle = "Telnet" & $sLine $result = Run(@ComSpec & " /c telnet " & $sline) if $result <> 0 Then Sleep(500) WinActivate($sWindowTitle) Sleep(200) Send("e") Sleep(300) Send("{ENTER}") Sleep(300) Send("*r?") Sleep(300) Send("{ENTER}") Sleep(300) Else MsgBox(0, "Error", "Failed to run Telnet for server '" & $sLine & "'!") EndIf WEnd Link to post Share on other sites
0xdefea7 10 Posted July 15, 2013 Share Posted July 15, 2013 Ctrl + T for Tidy Link to post Share on other sites
CHOVIE 1 Posted July 16, 2013 Author Share Posted July 16, 2013 (edited) @ YogiBear thank you for having a look .....will readup on the right way to use "case" ...... @ orbs thank you for having a look ..... and corrections ...... @ 0xdefea7 will try and remember that one .......... Sorry for the bad syntax but this was my first script I wrote and I am still learning the language and all the things associated with it ........... I have found my old installation of AutoIT (Version 1.79 Jul 16 2009 18:30:31) that I wrote the program in after tidying up some of the things in the script everything was working the way it should. I also found a typo from my side after an full investigation of 7500 code lines ...... I know there must be a easier and better way of repeating the same function for differant buttons but I am learing one step at a time ....... Thanks to everyone who had a look at this ......... Regards, CHOVIE Edited July 16, 2013 by CHOVIE ..... To Be The Best You Have To Beat The Best ..... Link to post Share on other sites
Solution CHOVIE 1 Posted July 16, 2013 Author Solution Share Posted July 16, 2013 @ All ....... Here are some .jpg`s on how it looks ............. 0xdefea7 1 ..... To Be The Best You Have To Beat The Best ..... Link to post Share on other sites
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