Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Transmitting Carriage Returns to wake system

Status
Not open for further replies.

mitelman

Technical User
Sep 28, 2002
292
0
0
CA
Hello All,

I am trying to create a script to do remote backups of PBX's. In order to log on I have to wake the system by pressing the return key between 5 and 10 times very quickly. If I put a simple Transmit ^M^M^M^M^M in my script it doesn't transmit fast enough an therefore doesn't always wake the PBX I have borrowed some code from a sample script with a while statement so that it will keep trying, but it doesn't transmit anything. See below for what I have so far.

Thanks,
Simon
mitelman


while FAILURE ;loop until we get desired response
if szLoop > 10
szExitcode = 1
hangup
goto Exitcode ;logs results of logon
endif
szLoop=szLoop+1
transmit "^M^M^M^M^M"
transmit "^M^M^M^M^M"
waitfor "VT-100" 1
endwhile
 
The first thing I would do is create a script that has just the transmit statement in it to make sure that the problem is not due to other parts of your script (such as the section with the transmit code never being executed for some reason).

Next, check the keyboard mapping for your Enter key to make sure that ^M is what the Enter key is sending. To do so, first make sure you are using the correct emulation, then select the Options | Keyboard Editor menu item in Procomm. Click once on the representation of the Enter key in Procomm and make sure that ^M is indeed what is being sent when the Enter key is pressed. If not, then you will need to modify your transmit statement to send the correct character sequence. aspect@aspectscripting.com
 
I had this working before the WHILE statement was put in, so I know that I can wake the system and that my ^M's are OK. The only problem with doing it that way is that I may not have enough carriage returns as some sites may take a lot more than others to wake up. I don't want to put in 25 carriage returns, because while one may need 15 ^M's the next may only need 4. So if I wake the system and keep transmitting I just fill my screen with logins. Also the carriage returns only seem to get transmitted about twice a second even though the transmit pacer is set to 0. Anyway to speed that up?

Thanks.
 
If it stopped working after you put the while in, then that tells us that it is is probably something with the while loop causing the problem. Are you intializing the value of szLoop before entering the while loop? If szLoop is zero the first time you enter the while loop, everything will work as expected. However, if this code gets executed a second time, you then enter the if clause and may potentially be exiting your script prematurely if sExitCode is still 1 from previous operations. This could explain why the carriage returns are not waking up the system. In cases like this, I will usually insert usermsg commands so that I can tell if I reached a certain area of the script, such as usermsg "entering if loop" or usermsg "transmitting carriage returns". You might want to add a couple usermsg commands to determine where you are at in the script and if everything is operating as expected.
aspect@aspectscripting.com
 
This is a different approach that eliminates the "waitfor" command. In your case, I think that your looping retrun keys could be missing the "vt-100" characters in the middle of the process. The best way to handle text that is not in a consistent location in the script is the "When - Target" commands. When the characters appear, it calls a subroutine. Makes it a little more compliacted, but it works.

I've added a LOGINPROMPT value that you set as a global variable by declaring it before any procedures including proc main. When your script receives "vt-100" it should call the subroutine that changes the value of LOGINPROMPT and stops the carriage return loop.

Code:
Integer LOGINPROMPT = 0
PROC MAIN
Integer szloop, szexitcode
When Target 1 "VT-100" call LOGGEDIN
while LOGINPROMPT == 0  ;loop until we get desired response
  if szLoop > 10
    szExitcode = 1
    hangup
    ;goto Exitcode  ;logs results of logon
  endif
  szLoop=szLoop+1
  transmit "^M^M^M^M^M"
  transmit "^M^M^M^M^M"
endwhile
EndProc

Proc LOGGEDIN
LOGINPROMPT = 1
EndProc
Robert Harris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top