VanDyke Software Forums

VanDyke Software Forums (https://forums.vandyke.com/index.php)
-   Scripting (https://forums.vandyke.com/forumdisplay.php?f=14)
-   -   Cannot escape to online command mode (modem) in script (https://forums.vandyke.com/showthread.php?t=13996)

conneryc 12-05-2019 11:38 AM

Cannot escape to online command mode (modem) in script
 
So I have a script to dial a locally attached modem to connect to remote modems connected to Cisco routers that I manage. Everything in the script works perfectly except getting the modem to hang up.

To do that, I have to send +++ to the connection to get to command mode with the modem to issue the ATH0 command to go on-hook.

This is the section of the script for that:

Code:

        crt.Screen.WaitForString ("Press RETURN to get started.")
                crt.Screen.Send "+++"
                crt.Screen.WaitForString ("OK")
                crt.Screen.Send "ATH0" & vbcr
                crt.Session.Disconnect
        Exit Sub

I'm using version 8.1.2 of SecureCRT

With echo on, I can see that the +++ is being sent by the script, but the modem doesn't see it. The script just pauses waiting for "OK". However, if I manually type the +++ on my keyboard the modem DOES see it and returns the "OK" and the script then sends the ATH0 and the modem hang up the line.

I can't seem to determine why the modem isn't getting the +++ from the script, but does when entered manually from the keyboard?

Thanks

jdev 12-05-2019 12:52 PM

Quote:

Originally Posted by conneryc (Post 52692)
With echo on, I can see that the +++ is being sent by the script, but the modem doesn't see it. The script just pauses waiting for "OK". However, if I manually type the +++ on my keyboard the modem DOES see it and returns the "OK" and the script then sends the ATH0 and the modem hang up the line.

I can't seem to determine why the modem isn't getting the +++ from the script, but does when entered manually from the keyboard?

The modem is receiving the +++, that's a certainty.

What's probably the issue here is that -- according to what I've briefly researched outside the scope of any SecureCRT involvement -- with a number of modems, the "+++" escape sequence has to be prefaced/followed by a 1-second delay in order for the modem to recognize it as an actual escape sequence (as opposed to just three '+' chars coming in as part of a normal data stream).

One thing that comes to mind is to try something to make it seem more like you're typing things in manually, by slowing things down a wee bit and introduce a 1-second delay before you send it. For example:

Code:

    crt.Screen.WaitForString "Press RETURN to get started."
    ' The escape sequence needs a 1-second delay before...
    crt.Sleep 1000

    ' Increase the character send delay to make it seem more
    ' like things are being typed in by a human -- instead of
    ' a machine... First, store the current char send delay:
    nOrigValue = crt.Session.Config.GetOption("Character Send Delay"))
    ' Next, set the value to 50 ms to simulate a fast typer
    crt.Session.Config.SetOption "Character Send Delay", 50

    ' Now, let's "send" the +++
    crt.Screen.Send "+++"

    ' Now, let's restore the char send delay to orig value
    crt.Session.Config.SetOption "Characters Send Delay", CINT(nOrigValue)

    crt.Screen.WaitForString "OK"
    crt.Screen.Send "ATH0" & vbcr

    crt.Session.Disconnect

Exit Sub

If that doesn't work, you'll need to explore and experiment with adjusting the timing/delay until you get a value set that works for sending the escape sequence to your modem.

--Jake

conneryc 12-05-2019 01:01 PM

Jake,

The "crt.Sleep 1000" command resolved the issue. Script working perfectly now.

Thank you!


All times are GMT -6. The time now is 06:40 PM.