Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Notices

Reply
 
Thread Tools Rating: Thread Rating: 3 votes, 5.00 average. Display Modes
  #1  
Old 10-10-2005, 08:00 PM
ceuso ceuso is offline
Registered User
 
Join Date: Oct 2005
Posts: 5
Debugging vb scripts

Hi,

how to debug vb and perl scripts.

Thank you
Reply With Quote
  #2  
Old 10-10-2005, 11:25 PM
jdev's Avatar
jdev jdev is offline
VanDyke Technical Support
 
Join Date: Nov 2003
Location: Albuquerque, NM
Posts: 1,099
I haven't personally used the script debugger with the perl language, but debugging VBScripts that run in SecureCRT should be possible by using the following steps. Microsoft documentation for the debugger states, "If you have installed an alternative scripting language that supports host-independent debugging, such as REXX or Perl, you can also debug scripts in that language", but I can't speak from experience with respect to perl so the example given below is provided in VBScript.
  1. Install the Microsoft Script Debugger tool.
  2. "Activate" the script debugger tool.
  3. Include the keyword "stop" within the script you are running, just above the point in the script that you would like the debugger to be launched.

Here are the details:

1. Install the Microsoft Script Debugger tool:
Download and install the Microsoft Windows Script Debugger for your particular Windows platform from the Microsoft scripting site:
http://www.microsoft.com/downloads/d...DisplayLang=en
2. "Activate" the script debugger tool.
Sometimes this step may not be necessary, but I just ran into an experience with a new computer recently in which the keyword "Stop" had no effect with respect to launching the script debugger. These are the steps I followed (not sure which ones are "required", but after I did these things, the "Stop" keyword worked to bring up the debugger):
- Write a simple VBScript that uses the "Stop" keyword. For example:
Code:
' TestDebug.vbs

Stop
Dim nIndex, nCounter
for nIndex = 1 to 100
    nCounter = nCounter + 1
Next
- Run the VBScript using a command similar to the following (path to your testdebug.vbs file may be different) from a command prompt or from within Start/Run:
wscript testdebug.vbs
If the debugger comes up automatically, you should now be able to debug scripts written for SecureCRT by including the "stop" keyword within your script code (Step 3 below).

- If the script debugger does not automatically come up -- which happened to me recently on a new machine -- you'll need to do what I call "Activating" the script debugger. There might be some registry entries that one could set instead of performing the following steps, but I didn't find any documentation from Microsoft, and unfortunately I didn't take snapshots of the registry before/after for comparison
To "activate the debugger", I ran the testdebug.vbs script such that it was launched within the debugger automatically by using a command line argument to the wscript application as in:
wscript //X testdebug.vbs
Then, I ran the testdebug.vbs script with a command line that enabled script debugging, as in:
wscript //D testdebug.vbs
If neither of the two previous steps work, you may need to manually edit the registry to turn on JIT (Just In Time) debugging for the WScript host. This is accomplished by setting the JITDebug registry REG_DWORD value to '1' in the following registry key location:
HKEY_CURRENT_USER\Software\Microsoft\Windows Script\Settings
Note: you may need to create the above REG_DWORD "JITDebug" value.


After I activated the script debugger using one or more of the steps above, and verified that the debugger actually came up each time I ran the testdebug.vbs script (SecureCRT wasn't involved yet... just plain Microsoft VBScripts), I then added the required header information for a SecureCRT script and the debugger launched when I ran the modified script from within SecureCRT.
3. Include the keyword "stop" within the SecureCRT script you are working on.
- On the line just before the segment of code that you wish to debug, insert the keyword "Stop" as in the example code provided above.

- Run the script from within SecureCRT as you normally would with Script/Run or using a keyboard shortcut, etc. Once the script interpreter encounters the "stop" keyword, the debugger should be launched and you should be able to step through your scripts, monitor the value of certain variables, etc. as described in the script debugger documentation provided by Microsoft:
http://msdn2.microsoft.com/en-us/library/ms532989.aspx

Appendix
The Microsoft Script Editor which ships with Office is much more user-friendly than the Microsoft Script Debugger interface (setting up watches, value-triggered break-points, etc). If you have office installed, you can activate the Microsoft Script Editor by following these steps:
  1. Uninstall the Microsoft Script Debugger
  2. Check to see if you already have the MS Script Editor installed. Check your MS Office program files location for the existence of a file named MSE7.exe. If you already have MSE7.exe on your system, launch the MS Script Editor and skip to step 4.
  3. If you don't already have the Microsoft Script Editor installed, bring up MS Excel or Word and in the main Tools menu, select Macro -> Microsoft Script Editor. You should receive prompts to install it if it's not yet installed.
  4. When the Microsoft Script Editor launches, choose Debug -> Install Web Debugging. Follow the prompts. Once this step completes, you should be able to verify script debugging is in place by running wscript //x <path to sample script.vbs>

Also, if you have MS DevStudio installed, you might also be able to use the built-in debugging tools there with the same user-friendly debugging features mentioned above.
__________________
Jake Devenport
VanDyke Software
Technical Support
YouTube Channel: https://www.youtube.com/vandykesoftware
Email: support@vandyke.com
Web: https://www.vandyke.com/support

Last edited by jdev; 11-24-2008 at 02:10 PM.
Reply With Quote
  #3  
Old 10-11-2005, 09:07 AM
ceuso ceuso is offline
Registered User
 
Join Date: Oct 2005
Posts: 5
Thanks a lot. I will test ...
Reply With Quote
  #4  
Old 10-18-2005, 02:19 AM
rbeezley rbeezley is offline
Registered User
 
Join Date: Sep 2005
Posts: 4
Contents of variables

Is there an eaiser way than the command window to see the contents of your variables?
Reply With Quote
  #5  
Old 10-24-2005, 06:38 PM
jdev's Avatar
jdev jdev is offline
VanDyke Technical Support
 
Join Date: Nov 2003
Location: Albuquerque, NM
Posts: 1,099
Quote:
Originally Posted by rbeezley
Is there an eaiser way than the command window to see the contents of your variables?
Using the Microsoft Script Editor (ships with some MS products, such as Office XP, etc), you can set up Watches and cool things like that. Otherwise, I don't know of an easier way within the plain MS script debugger to do it any easier than the ?Varname method within the command window.
__________________
Jake Devenport
VanDyke Software
Technical Support
YouTube Channel: https://www.youtube.com/vandykesoftware
Email: support@vandyke.com
Web: https://www.vandyke.com/support
Reply With Quote
Reply

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 -6. The time now is 01:11 PM.