Sign in to follow this  
Followers 0
CHOVIE

Script running in a loop

6 posts in this topic

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 .....

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
Share on other sites

Ctrl + T for Tidy :)

Share this post


Link to post
Share on other sites

#5 ·  Posted (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 ...... :oops: 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 ....... :thumbsup:

Thanks to everyone who had a look at this ......... 

Regards,

CHOVIE

Edited by CHOVIE

..... To Be The Best You Have To Beat The Best .....

Share this post


Link to post
Share on other sites

@ All .......

Here are some .jpg`s on how it looks .............

post-58813-0-89925300-1373975874_thumb.j

post-58813-0-71778200-1373975886_thumb.j

post-58813-0-44661900-1373975898_thumb.j

post-58813-0-62730900-1373975909_thumb.j

1 person likes this

..... To Be The Best You Have To Beat The Best .....

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0