VanDyke Software Forums

Go Back   VanDyke Software Forums > Scripting
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 04-22-2012, 02:23 PM
owensbuddy owensbuddy is offline
Registered User
 
Join Date: Jan 2012
Posts: 2
Recorded scripts littered with junk lines

Hello,

I am a Marriott employee and have been using SecureCRT's scripting functionality for some time now with lots of success. But the automated "record script" functionality does not work because every other line of code is... well... garbage. See below. If I could figure out why, perhaps others would be able to make their own scripts and run them. Here is an example of the automated script that gets recorded:

Code:
#$language = "VBScript"
#$interface = "1.0"

' This automatically generated script may need to be
' edited in order to work correctly.

Sub Main
	crt.Screen.Send "1" & chr(13)
	crt.Screen.WaitForString chr(27) & "[21;1H" & chr(27) & "[20;47H" & chr(27) & "[1;1H" & chr(27) & "[m" & chr(27) & "(B" & chr(27) & "[1;55HF" & chr(27) & "[1;77H30" & chr(27) & "[3;26HF" & chr(27) & "[3;28HR" & chr(27) & "[3;30HO" & chr(27) & "[3;32HN" & chr(27) & "[3;34HT" & chr(27) & "[3;38HO" & chr(27) & "[3;40HF" & chr(27) & "[3;42HF" & chr(27) & "[3;44HI" & chr(27) & "[3;46HC" & chr(27) & "[3;48HE" & chr(27) & "[3;50H " & chr(27) & "[3;52HM" & chr(27) & "[3;54HE" & chr(27) & "[3;56HN" & chr(27) & "[3;58HU" & chr(27) & "[4;55H====" & chr(27) & "[6;3H1." & chr(27) & "[6;7HRESERVATIONS" & chr(27) & "[6;20HMENU" & chr(27) & "[6;26H  " & chr(27) & "[6;30H     " & chr(27) & "[6;36H     10.  GUEST" & chr(27) & "[6;52HCREDIT" & chr(27) & "[6;59HMENU" & chr(27) & "[7;3H2." & chr(27) & "[7;7HREGISTRATION" & chr(27) & "[7;20HMENU" & chr(27) & "[7;26H  " & chr(27) & "[7;30H        " & chr(27) & "[7;39H  11.  NIGHT A" & chr(27) & "[7;54HDIT" & chr(27) & "[7;58HMENU" & chr(27) & "[8;3H3." & chr(27) & "[8;7HROOM" & chr(27) & "[8;12HSTATUS" & chr(27) & "[8;19HUPDATE" & chr(27) & "[8;26H  " & chr(27) & "[8;30H     " & chr(27) & "[8;36H     12.  DIRECT SAL" & chr(27) & "[8;57H POSTING" & chr(27) & "[9;3H4." & chr(27) & "[9;7HTYPE" & chr(27) & "[9;12HINVENTORY" & chr(27) & "[9;22HDISPLAY" & chr(27) & "[9;30H   " & chr(27) & "[9;34H    " & chr(27) & "[9;41H13." & chr(27) & "[9;46HCURRENCY" & chr(27) & "[9;55HEXCHANGE" & chr(27) & "[10;3H5." & chr(27) & "[10;7HROOM" & chr(27) & "[10;12HAVAILABILITY" & chr(27) & "[10;25HDISPLAY      " & chr(27) & "[10;39H  14." & chr(27) & "[10;46HGUEST" & chr(27) & "[10;52HHISTORY" & chr(27) & "[10;60HMENU" & chr(27) & "[11;3H6." & chr(27) & "[11;7HREPORT" & chr(27) & "[11;14HMENU" & chr(27) & "[11;26H  " & chr(27) & "[11;30H           15.  AUTO-ROOM" & chr(27) & "[11;56HINHIBIT" & chr(27) & "[11;64HSELECTION" & chr(27) & "[12;3H7." & chr(27) & "[12;7HGUEST" & chr(27) & "[12;13HACCOUNTING" & chr(27) & "[12;24H/" & chr(27) & "[12;26HCHECK-OUT" & chr(27) & "[12;41H16." & chr(27) & "[12;46HEMPLOYEE" & chr(27) & "[12;55HPASSWORD" & chr(27) & "[12;64HRESET" & chr(27) & "[13;3H8." & chr(27) & "[13;7HBATCH" & chr(27) & "[13;13HCHARGE" & chr(27) & "[13;20HPOSTING " & chr(27) & "[13;30H     " & chr(27) & "[13;36H     17.  P" & chr(27) & "[13;48HS/6000" & chr(27) & "[13;55HPRINTER" & chr(27) & "[13;63HQUEUE" & chr(27) & "[13;69HMAINTENANCE" & chr(27) & "[14;3H9." & chr(27) & "[14;7HSHIFT" & chr(27) & "[14;13HCLOSING" & chr(27) & "[14;21HMENU" & chr(27) & "[14;26H  " & chr(27) & "[14;30H         " & chr(27) & "[14;40H 18." & chr(27) & "[14;46HSYSTEM" & chr(27) & "[14;53HRESOURCE" & chr(27) & "[14;62HUSAGE" & chr(27) & "[15;25H   " & chr(27) & "[15;30H        " & chr(27) & "[15;39H  19." & chr(27) & "[15;45H " & chr(27) & "[15;47HMPLOYEE LOGON" & chr(27) & "[15;61HMESSAGES" & chr(27) & "[15;70HMENU" & chr(27) & "[16;25H   " & chr(27) & "[16;30H       " & chr(27) & "[16;38H          " & chr(27) & "[16;49H    " & chr(27) & "[17;7HENTER" & chr(27) & "[17;13HSELECTION:" & chr(27) & "[;1m" & chr(27) & "(B" & chr(27) & "[17;25H   " & chr(27) & "[17;30H        " & chr(27) & "[17;39H        " & chr(27) & "[17;48H  " & chr(27) & "[m" & chr(27) & "(B   " & chr(27) & "[18;25H   " & chr(27) & "[18;30H        " & chr(27) & "[18;39H       " & chr(27) & "[18;47H     " & chr(27) & "[18;53H           " & chr(27) & "[20;30H     " & chr(27) & "[20;36H          " & chr(27) & "[20;47H " & chr(27) & "[24;80H" & chr(27) & "[1;49H" & chr(27) & "[17;24H"
	crt.Screen.Send "2" & chr(13)
	crt.Screen.WaitForString chr(27) & "[18;1H" & chr(27) & "[17;24H" & chr(27) & "[1;1H" & chr(27) & "[m" & chr(27) & "(B" & chr(27) & "[1;56HREG  " & chr(27) & "[1;78H1" & chr(27) & "[2;24HR" & chr(27) & "[2;26HE" & chr(27) & "[2;28HG" & chr(27) & "[2;30HI" & chr(27) & "[2;32HS" & chr(27) & "[2;34HT" & chr(27) & "[2;36HR" & chr(27) & "[2;38HA" & chr(27) & "[2;40HT" & chr(27) & "[2;42HI" & chr(27) & "[2;44HO" & chr(27) & "[2;46HN" & chr(27) & "[2;50HM" & chr(27) & "[2;52HE" & chr(27) & "[2;54HN" & chr(27) & "[2;56HU" & chr(27) & "[3;24H=================================" & chr(27) & "[3;58H " & chr(27) & "[4;26H                                 " & chr(27) & "[5;21H1." & chr(27) & "[5;25HGUEST" & chr(27) & "[5;31HREGISTRATION" & chr(27) & "[5;44H/" & chr(27) & "[5;46HCHECK-IN" & chr(27) & "[6;3H  " & chr(27) & "[6;7H            " & chr(27) & "[6;20H 2. " & chr(27) & "[6;25HWALKED" & chr(27) & "[6;32HGUEST" & chr(27) & "[6;38HLOCATOR" & chr(27) & "[6;46H     " & chr(27) & "[6;52H      " & chr(27) & "[6;59H    " & chr(27) & "[7;3H  " & chr(27) & "[7;7H            " & chr(27) & "[7;20H 3. " & chr(27) & "[7;25HGUEST" & chr(27) & "[7;31HACCOUNTING / CHECK-OUT    " & chr(27) & "[7;58H    " & chr(27) & "[8;3H  " & chr(27) & "[8;7H    " & chr(27) & "[8;12H      " & chr(27) & "[8;19H  4.  REGISTRATION" & chr(27) & "[8;38HQUESTION      " & chr(27) & "[8;53H    " & chr(27) & "[8;58H       " & chr(27) & "[9;3H  " & chr(27) & "[9;7H    " & chr(27) & "[9;12H         5.  A" & chr(27) & "[9;27HTERNATE" & chr(27) & "[9;35HROOM" & chr(27) & "[9;40HTYPES" & chr(27) & "[9;46H        " & chr(27) & "[9;55H        " & chr(27) & "[10;3H  " & chr(27) & "[10;7H    " & chr(27) & "[10;12H         6. " & chr(27) & "[10;25HPRINT KEY" & chr(27) & "[10;35HPACKETS  " & chr(27) & "[10;46H     " & chr(27) & "[10;52H       " & chr(27) & "[10;60H    " & chr(27) & "[11;3H  " & chr(27) & "[11;7H      " & chr(27) & "[11;14H    " & chr(27) & "[11;21H7." & chr(27) & "[11;25HROOM" & chr(27) & "[11;30HSTATUS" & chr(27) & "[11;37HUPDATE " & chr(27) & "[11;46H         " & chr(27) & "[11;56H       " & chr(27) & "[11;64H         " & chr(27) & "[12;3H  " & chr(27) & "[12;7H     " & chr(27) & "[12;13H        8." & chr(27) & "[12;24H GUEST CHARGE" & chr(27) & "[12;38HROUTING/SETTLEM" & chr(27) & "[12;54HNT MENU  " & chr(27) & "[12;64H     " & chr(27) & "[13;3H  " & chr(27) & "[13;7H     " & chr(27) & "[13;13H      " & chr(27) & "[13;20H 9.  MANUAL" & chr(27) & "[13;32HBLOCKER" & chr(27) & "[13;41H   " & chr(27) & "[13;46H        " & chr(27) & "[13;55H       " & chr(27) & "[13;63H     " & chr(27) & "[13;69H           " & chr(27) & "[14;3H  " & chr(27) & "[14;7H     " & chr(27) & "[14;13H       10.  CONSECUTIVE" & chr(27) & "[14;37HNIGHTS AVAILABILITY     " & chr(27) & "[14;62H     " & chr(27) & "[15;20H11." & chr(27) & "[15;25HAUTO-ROOM" & chr(27) & "[15;35HINHIBIT SEL" & chr(27) & "[15;47HCTI" & chr(27) & "[15;51HN  " & chr(27) & "[15;55H     " & chr(27) & "[15;61H        " & chr(27) & "[15;70H    " & chr(27) & "[16;20H12." & chr(27) & "[16;25HMARSHA" & chr(27) & "[16;32HRESERVATIONS" & chr(27) & "[16;45HMENU" & chr(27) & "[17;7H     " & chr(27) & "[17;13H       13." & chr(27) & "[17;24H ROOM" & chr(27) & "[17;30HSTATUS" & chr(27) & "[17;37HCHANGE" & chr(27) & "[17;44HDISPLAY/REPORT" & chr(27) & "[18;20H14." & chr(27) & "[18;25HPMS/6000" & chr(27) & "[18;34HPRINTER" & chr(27) & "[18;42HQUEUE" & chr(27) & "[18;48HMAINTENANCE" & chr(27) & "[19;20H15." & chr(27) & "[19;25HELECTRONIC" & chr(27) & "[19;36HLOCK" & chr(27) & "[19;41HFUNCTIONS" & chr(27) & "[20;20H16." & chr(27) & "[20;25HCERTIFICATE" & chr(27) & "[20;37HREPORT" & chr(27) & "[22;25HENTER" & chr(27) & "[22;31HSELECTION:" & chr(27) & "[;1m" & chr(27) & "(B" & chr(27) & "[m" & chr(27) & "(B" & chr(27) & "[24;80H" & chr(27) & "[1;49H" & chr(27) & "[22;42H"
	crt.Screen.Send "1" & chr(13)
	crt.Screen.WaitForString chr(27) & "[23;1H" & chr(27) & "[22;42H" & chr(27) & "[H" & chr(27) & "[2J" & chr(27) & "[7;26H" & chr(27) & "[7;32HSAWGRASS" & chr(27) & "[7;41HMARRIOTT" & chr(27) & "[7;56H" & chr(27) & "[8;26H" & chr(34) & chr(34) & chr(34) & chr(34) & chr(34) & chr(34) & chr(34) & chr(34) & chr(34) & chr(34) & chr(34) & chr(34) & chr(34) & chr(34) & chr(34) & chr(34) & chr(34) & chr(34) & chr(34) & chr(34) & chr(34) & chr(34) & chr(34) & chr(34) & chr(34) & chr(34) & chr(34) & chr(34) & chr(34) & chr(34) & chr(27) & "[9;29HR-E-G-I-S-T-R-A-T-I-O-N" & chr(27) & "[11;37H01/21/12" & chr(27) & "[18;1H<1>ROOM" & chr(27) & "[18;9HNUMBER" & chr(27) & "[18;27H<3>WALKIN" & chr(27) & "[18;53H<5>TYPE" & chr(27) & "[18;61HINVENTORY" & chr(27) & "[19;1H<2>NAME" & chr(27) & "[19;9HSEARCH" & chr(27) & "[19;27H<4>ROOM" & chr(27) & "[19;35HAVAILABILITY" & chr(27) & "[19;53H<6>REDEMPTION" & chr(27) & "[19;67HWALKIN" & chr(27) & "[21;1HENTER" & chr(27) & "[21;7HRESV" & chr(27) & "[21;12H#," & chr(27) & "[21;15HSWIPE" & chr(27) & "[21;21HCREDIT" & chr(27) & "[21;28HCARD," & chr(27) & "[21;34HC=CONF#" & chr(27) & "[21;42HOR" & chr(27) & "[21;45HOPTION:" & chr(27) & "[21;53H" & chr(27) & "[22;1H"
	crt.Screen.Send "5" & chr(13)
	crt.Screen.WaitForString chr(27) & "[23;1H" & chr(27) & "[H" & chr(27) & "[2J" & chr(27) & "[3;1H" & chr(27) & "[3;80H" & chr(27) & "[3;1HCOMPLEX" & chr(27) & "[3;9H[" & chr(27) & "[3;11H1]:"
	crt.Screen.Send chr(13)
End Sub
As you can see these wait for string lines go on forever. I have to manually delete them.

Any idea why it gets recorded like this?

Thanks in advance,

Buddy
Reply With Quote
  #2  
Old 04-23-2012, 06:40 AM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 3,265
Hi Buddy,

Thanks for the question. It looks like you are attempting to record a script to interact with a remote program rather than a remote shell. The script recorder is attempting to record a unique string out of what the remote program sends in response to the data you send. The WaitForString() line is a capture of the data that the remote is sending.

You can manually edit the script (as is often necessary) that is generated and change the data captured by the script recorder to wait for something that is unique, but not as long. The important thing to remember is that you have to wait for something that is guaranteed to be an indicator that the remote program is ready to receive input.

Since you are attempting to automate interacting with a remote program, you may want to enable the IgnoreEscape property of the Screen object since the remote program is sending so many escape sequences to paint the program to the terminal window.

Does this help to answer your question?
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote
  #3  
Old 05-05-2012, 06:17 AM
owensbuddy owensbuddy is offline
Registered User
 
Join Date: Jan 2012
Posts: 2
RTB,

Thanks for the great reply but I have to admit that some of it is a bit over my head.

Are you saying that there is a way to have SecureCRT only record unique keystrokes and ignore these long garbage lines?

As it is It is pretty quick and easy to manually edit this code to make it function Ė I just pull up something like Notepad++ and search for all Ďwaitforstringí, bookmark the line, then remove bookmarked lines. But itís easier for me to just write my own script. Iím more interested in the possibility that others at my property can also save a lot of time with macros without having to edit the VBscript by hand.


Iíve discovered two things that may help explain whatís going on.
1.) Log files also record garbage script. A .log file doesnít record anything useful, just garbage. It would be nice to keep a history of what weíve done.

2.) Synchronous=true does not help. If I have a simple script to send a series of keystrokes, thereís a 50% chance that with synchronous= true, it will fail because our system canít keep up. The waitforstring also doesnít work so I loop a screen.get(y,x1,y,x2) until the expected string means the screen is ready to continue.

Iíve asked our own Marriott Support about this and surprisingly they have no idea. Itís crazy to me that we use this outstanding software you guys have created and nobody Iíve spoken to yet knows how to use these awesome functions youíve built in.

Please excuse my ignorance. Any help you can provide will be greatly appreciated.

Buddy
Reply With Quote
  #4  
Old 05-07-2012, 09:23 AM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 3,265
Hi Buddy,

Thanks for the update.
Quote:
Are you saying that there is a way to have SecureCRT only record unique keystrokes and ignore these long garbage lines?
I am saying that it is often necessary to edit the recorded scripts because the script recorder doesn't have a way to make human-like decisions regarding what is and is not necessary. The "long garbage lines" are not garbage. They are what the script recorder is capturing. The remote is sending the information captured by the script recorder, and the long line is what the script recorder considers unique. When waiting for the remote device to be ready for input, it is necessary to wait for a unique string that will be received from the remote. It is also possible to accomplish the same thing by causing the script to wait using the Sleep() method, but this is not nearly as efficient and may fail.
Quote:
As it is It is pretty quick and easy to manually edit this code to make it function – I just pull up something like Notepad++ and search for all ‘waitforstring’, bookmark the line, then remove bookmarked lines. But it’s easier for me to just write my own script. I’m more interested in the possibility that others at my property can also save a lot of time with macros without having to edit the VBscript by hand.
Removing the WaitForString() lines is why the script does not reliably run with or without setting the Synchronous property to True. The IgnoreEscape property would allow the script to ignore any escape sequences when waiting to find a match in the data that the remote device is sending. Enabling this property may be a way to use the WaitForString() method reliably.
Quote:
1.) Log files also record garbage script. A .log file doesn’t record anything useful, just garbage. It would be nice to keep a history of what we’ve done.
How have you configured logging in SecureCRT?
Quote:
2.) Synchronous=true does not help. If I have a simple script to send a series of keystrokes, there’s a 50% chance that with synchronous= true, it will fail because our system can’t keep up. The waitforstring also doesn’t work so I loop a screen.get(y,x1,y,x2) until the expected string means the screen is ready to continue.
Using the Get() method is not a solution I would have considered, but it sounds like it works well for you. This may be the best solution to use to accomplish your goal.
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 06:53 AM.


© copyright 1995-2014 VanDyke Software, Inc.