Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Reply
 
Thread Tools Rate Thread Display Modes
  #76  
Old 05-07-2015, 01:59 PM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,306
Hi emexy,

Thanks for the confirmation. I am glad that we could help.
__________________
--Todd

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote
  #77  
Old 05-13-2015, 12:27 PM
fixit9660 fixit9660 is offline
Registered User
 
Join Date: Apr 2015
Posts: 23
Falling at the first hurdle

Hi,
I'm getting a CRT Script Runtime error: The Session Option was not found: Auth Prompts in Window.
It's failing at Line 108 of the .vbs version
Any ideas please?
Also my commands include slashes: /i/l2/vlan
and I think I saw some mention in the script to remove these?
Running on Windoze Server 2007 Standard Version SP2
Thanks
Andy.
Reply With Quote
  #78  
Old 05-13-2015, 12:50 PM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,474
Hello Andy,

What version of SecureCRT are you using?

It seems it must be quite an old version, one that predates when we added this option:

Changes in SecureCRT 6.1 (Beta 1) -- June 19, 2008
--------------------------------------------------

New features:

  • SSH1/SSH2: Added an option for authentication credentials to be entered in the terminal window, which allows Secure Shell logons to be scripted using the Expect/Send strings or "Logon script" option found in the Session Options dialog.
You can check your upgrade eligibility here.

If you do not have the ability to use a more recent version of SecureCRT, then you will probably have to edit the script accordingly (running commands only *after* you have successfully connected and authenticated).


Quote:
Also my commands include slashes: /i/l2/vlan
and I think I saw some mention in the script to remove these?
I also do not see the comments in the script you referenced above. I do not believe that is the issue.
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #79  
Old 05-13-2015, 01:25 PM
fixit9660 fixit9660 is offline
Registered User
 
Join Date: Apr 2015
Posts: 23
Hi bgagnon.

I'm using 7.3.1 x64 Build 685. Fairly up to date.

And lines 261-264 read:
' Replace any illegal characters that might have been
' introduced by the command we're running (e.g. if the
' command had a path or a pipe in it)
strCleanCmd = Replace(strCommand, "/", "[SLASH]")

..so at a brief glance I believed that the script was stipping out the "/" I need to be entered as a Command.

This is two separate issues by the way; The initial Runtime Error, and a "/" stripping question.
Reply With Quote
  #80  
Old 05-13-2015, 01:38 PM
fixit9660 fixit9660 is offline
Registered User
 
Join Date: Apr 2015
Posts: 23
OK. Hang on. Looking at my screen more closely it's trying to connect via COM2 Serial. I've set the Default Session to SSH and now it's connecting.

And I'm apparently correct as it has executed an "info" command, but not the "/i/l2/vlan" command immediately after it.

Last edited by fixit9660; 05-13-2015 at 02:07 PM.
Reply With Quote
  #81  
Old 05-13-2015, 01:55 PM
fixit9660 fixit9660 is offline
Registered User
 
Join Date: Apr 2015
Posts: 23
OK so I've fixed that; It needed a Default SSH Session.
Now it's executing the first two "ordinary" commands, which are "lines 0", and "info", but it now waits at the ".....#" system prompt, until I enter a "/<CR>" when it executes the next command, this being the command "/i/l2/vlan". Then it waits again at the ".....#" system prompt, until I enter another "/<CR>" when it executes the next command.

I've just noticed that none of the output filenames have the "/" commands in them, just 10.206.79.37----2015-05-13--19'43'09.txt.

What is causing these 3 issues please?

Last edited by fixit9660; 05-13-2015 at 02:09 PM.
Reply With Quote
  #82  
Old 05-13-2015, 02:13 PM
fixit9660 fixit9660 is offline
Registered User
 
Join Date: Apr 2015
Posts: 23
If I continue entering further manual "/<CR>" entries, I actually get to the end of the "commands" list and it exits the script cleanly. I'm also now getting output files with the correct commands in the filename:
10.206.79.37--[SLASH]i[SLASH]l2[SLASH]vlan--2015-05-13--20'13'20.txt

So, all I need to fix is the need for a manual "/<CR>" entry for all the commands that start with a "/".
Reply With Quote
  #83  
Old 05-13-2015, 02:25 PM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,474
Hello Andy,

I am glad to hear you were able to resolve the line 108 error.

With respect to lines 261-264, that comment is regarding creating the log filename. Since those characters (handled by lines 265-273) are invalid as part of a filename on Windows operating systems, *if* you choose to use the templated log filename from lines 36-37, then the block of code is designed to "clean up" what ultimately replaces COMMAND:

Code:
g_strLogFileTemplate = _
    g_strMyDocs & "\##IPADDRESS--COMMAND--YYYY-MM-DD--hh'mm'ss.txt"
Quote:
I've just noticed that none of the output filenames have the "/" commands in them, just 10.206.79.37----2015-05-13--19'43'09.txt.
Have you altered the above log file template?

Or any other lines involved in creating the log filename (lines 257-275)?


Quote:
Now it's executing the first two "ordinary" commands, which are "lines 0", and "info", but it now waits at the ".....#" system prompt, until I enter a "/<CR>" when it executes the next command, this being the command "/i/l2/vlan". Then it waits again at the ".....#" system prompt, until I enter another "/<CR>" when it executes the next command.
If you were doing this without the script, would you have to enter "/<CR>"?

Is the prompt any different when you have to enter "/<CR>" versus the commands that are being executed from the commands file?
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #84  
Old 05-13-2015, 02:47 PM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,474
Hello Andy,

I am reposting (and clarifying) my prior response because I was in the middle of writing my response when you posted the later update. I am glad to hear you were able to resolve the logging issue.


Quote:
Now it's executing the first two "ordinary" commands, which are "lines 0", and "info", but it now waits at the ".....#" system prompt, until I enter a "/<CR>" when it executes the next command, this being the command "/i/l2/vlan". Then it waits again at the ".....#" system prompt, until I enter another "/<CR>" when it executes the next command.
If you were doing this without the script, would you have to enter "/<CR>"?

In other words, does this put the remote into some special mode (enable mode)?

Is the prompt any different when you have to enter "/<CR>" versus the commands that are being executed from the commands file?
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730

Last edited by bgagnon; 05-13-2015 at 02:48 PM. Reason: quoting failed
Reply With Quote
  #85  
Old 05-13-2015, 02:59 PM
fixit9660 fixit9660 is offline
Registered User
 
Join Date: Apr 2015
Posts: 23
Quote:
If you were doing this without the script, would you have to enter "/<CR>"?
No, I'd just enter the command as /i/l2/vlan<CR>

Quote:
Is the prompt any different when you have to enter "/<CR>" versus the commands that are being executed from the commands file?
Well the whole line is different; it changes with every menu change, but it still ends in a "# ". Does that make a difference?

Example: Just signed in =
">> LPBE004 - ADC-VX - Main# " (without the inverted commas)

where I enter the "info" command. This then changes to the information menu, and the prompt changes accordingly:
">> LPBE004 - ADC-VX - Information# " and it does this for every menu, and every host has a different hostname, in this case the "LPBE004" portion of the prompt.
So when I'm at the ">> LPBE004 - ADC-VX - Information# " prompt, it's waiting, and I enter the "/<CR>" I am in fact changing the prompt totally because it reverts to ">> LPBE004 - ADC-VX - Main# "

Now that is interesting; if I rearrange the commands sequence to that the "info" command is after the "/i/l2/vlan" command, it works! But the info command now waits for the "/<CR>" input.

It's obviously something to do with the prompt.
Reply With Quote
  #86  
Old 05-13-2015, 03:04 PM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,474
Hi Andy,

Thanks for the update.

Quote:
Well the whole line is different; it changes with every menu change, but it still ends in a "# ". Does that make a difference?
Possibly, because the script is designed to detect the prompt after initial logon (see lines 185-195).

If the # is common for all your prompts (and there is no chance of it being used as part of the output results after running a command), then you could likely just hard-code it:

Code:
strPrompt = "#"
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730

Last edited by bgagnon; 05-13-2015 at 03:04 PM. Reason: stray space
Reply With Quote
  #87  
Old 05-13-2015, 04:29 PM
fixit9660 fixit9660 is offline
Registered User
 
Join Date: Apr 2015
Posts: 23
There are lots of "*" in the various outputs, even "* " but no "* <CR>" which a Hex dump shows being sent. Can we trigger on that please?
Reply With Quote
  #88  
Old 05-14-2015, 07:51 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,474
Hi Andy,

I am not sure what you mean by your latest post.

So far we have talked about # as the prompt and the fact you have to manually enter "/<CR>" to get the script to continue.

When did * enter the conversation?

What do you mean by "Can we trigger on that please?"?
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #89  
Old 05-19-2015, 03:50 AM
fixit9660 fixit9660 is offline
Registered User
 
Join Date: Apr 2015
Posts: 23
Quote:
There are lots of "*" in the various outputs, even "* " but no "* <CR>" which a Hex dump shows being sent. Can we trigger on that please?
D'OH!! Typo I'm so sorry! I should have typed:

There are lots of "#" in the various outputs, even "# " but no "# <CR>", or more specifically "23 20 0d 0a" which a Hex dump shows being sent. Can we trigger on that please?

Apologies

Last edited by fixit9660; 05-19-2015 at 03:57 AM.
Reply With Quote
  #90  
Old 05-19-2015, 12:30 PM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,474
Hi Andy,

Information along those lines was previously given:

Quote:
If the # is common for all your prompts (and there is no chance of it being used as part of the output results after running a command), then you could likely just hard-code it:

Code:
strPrompt = "#"
__________________
Thanks,
--Brenda

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

Tags
example script


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