Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Reply
 
Thread Tools Rate Thread Display Modes
  #91  
Old 05-19-2015, 11:51 AM
fixit9660 fixit9660 is offline
Registered User
 
Join Date: Apr 2015
Posts: 23
The problem is that 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.

I'm hoping that the script could be made to recognise "23 20 0d 0a" as a prompt?
Reply With Quote
  #92  
Old 05-19-2015, 01:43 PM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 3,945
Hi Andy,

No, sorry, at present you cannot "waitfor" hex codes in SecureCRT (nor can you view or send data in hex).

Let's back up a second and see if there isn't a better way to approach this.

You posted previously:

Quote:
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)
What do you mean by "menu change"?

Does the unique portion of the prompt that precedes "#[SP]" have any relationship to the actual connection?

For example, is it first the actual hostname of the device ("hostname#[SP]"), then when you enter "enable mode" or whatever special config mode you need to handle *inside* a connection, is it then just altered accordingly (ie: "hostname[config]#[SP]")?

Please elaborate on what the various prompts reflect and if there is any discernible pattern between the devices you need to connect to using the script.
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #93  
Old 05-19-2015, 02:24 PM
fixit9660 fixit9660 is offline
Registered User
 
Join Date: Apr 2015
Posts: 23
Unhappy

Hi Brenda,

For background, I'm logging into a Radware Alteon 10000, but the CLI is similar for all the range.
The prompt consists of an amalgam of ">>", then hostname, ie "LPBE004", then "-", then virtual device "ADC-VX -", then the submenu "Main" followed by "# ".
If you change menu by entering "/i" for Information the menu changes to
>> LPBE004 - ADC-VX - Info#
If you then enter a sub menu by entering the command "sys" (for system information), the prompt then changes to
>> LPBE004 - ADC-VX - System# and so on.
(If you really can't sleep then https://cs.uwaterloo.ca/twiki/pub/CF...itchCmdRef.pdf will show you the command line syntax, albeit for different hardware).
So you can see that the prompt is really variable depending upon which device you are on, and where in its menu structure you are.
The only constant is the "# " at the end.
Reply With Quote
  #94  
Old 05-19-2015, 03:59 PM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 3,945
Hi Andy,

It will be possible to accomplish your objective, but it will take some manipulation of your commands file.

In the commands file before any commands are issued that take you into any of these "special submenus", you would need to enter something signifying that on the prior line.

For example:
NormalCommand1
NormalCommand2
##--NewPrompt--##: Info
/i
##--NewPrompt--##: System
sys


Then, you can add to the example script the code that will recognize when you are going to enter a "special submenu" and change the prompt SecureCRT "waits for" accordingly.

It would be in the For/Next loop that begins at line 198 in the example script and you would essentially want to check:
  • Is this my special command line?
  • If so, parse the data to get what follows the :
  • Set the prompt you are waiting for to be that variable
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #95  
Old 05-20-2015, 01:42 AM
fixit9660 fixit9660 is offline
Registered User
 
Join Date: Apr 2015
Posts: 23
Thanks Brenda. I wasn't aware it was possible to change the script prompt expectations from the Commands.txt file. Very useful!
I'll look at the script changes and work on it. (Might take me a while as I'm on holiday for a week from tomorrow).

Many thanks

Andy.
Reply With Quote
  #96  
Old 05-20-2015, 09:00 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 3,945
Hi Andy,

Sounds good, enjoy your holiday!
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #97  
Old 10-08-2015, 08:17 PM
djdumlao djdumlao is offline
Registered User
 
Join Date: Oct 2015
Posts: 2
Will this script work on Python version 3

RTB and Vandyke team Will this script work on Python version 3?

Last edited by rtb; 10-09-2015 at 08:03 AM. Reason: Removing cruft from post
Reply With Quote
  #98  
Old 10-09-2015, 08:03 AM
rtb rtb is offline
VanDyke Technical Support
 
Join Date: Aug 2008
Posts: 4,306
Hi djdumlao,

Since SecureCRT 7.3 for Windows includes Python 2.6 and SecureCRT on Mac OS X, RHEL and Ubuntu use Python 2.7 (which should already exist on the system), we haven't tested the script with Python 3.x.

The script is intended to be run from within SecureCRT.

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

VanDyke Software
Technical Support
support@vandyke.com
505-332-5730
Reply With Quote
  #99  
Old 03-23-2016, 09:02 AM
splicer72 splicer72 is offline
Registered User
 
Join Date: Oct 2011
Posts: 3
Use a hostname instead of IP to name file

Hi Todd
The script is working fine for me as it is but am trying to amend two things with little luck.
I would like to use a hostname to name the log file, i had a similar script that used a single file i.e hostname:ip:ssh but that does not work on the network i am currently working on
The other change is that I would like to be able to place all of the output into a single file as opposed to multiple files. I have tried looking at how to do this but am a bit stumped.
Any ideas would be greatly appreciated

Thanks in advance


Colin
Reply With Quote
  #100  
Old 03-23-2016, 09:25 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 3,945
Hi Colin,

We do have such an example script (log to one file).

Please send an email to support@vandyke.com and reference "Attn Brenda - Forum Thread #10651". I will provide further guidance on how to accomplish the naming convention you desire via email.
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #101  
Old 03-24-2016, 09:27 AM
sranbala sranbala is offline
Registered User
 
Join Date: Mar 2016
Posts: 10
New host key issue

I am using this script to automate some of my work, I have a challenge, Whenever the script login to new host(ip address) It prompts below and which i have to manually accept. Is there a way to auto accept it..

"The host key database does not contain an entry for the
hostname
It is recommended you verify your host key before accepting"
Reply With Quote
  #102  
Old 03-24-2016, 10:58 AM
jdev's Avatar
jdev jdev is offline
VanDyke Technical Support
 
Join Date: Nov 2003
Location: Albuquerque, NM
Posts: 922
Quote:
Originally Posted by sranbala View Post
...Whenever the script login to new host(ip address) It prompts below and which i have to manually accept. Is there a way to auto accept it.. "The host key database does not contain an entry for the
hostname

It is recommended you verify your host key before accepting"
Properly verifying host keys is essential to the security of the SSH2 protocol. If you don't verify the host key you are subjecting yourself to MITM attacks where a hacker will pretend to be the host you're trying to get to, and intercept/store/forward information on your behalf to the real server, gaining access to your username, your password, and all other data passed between your machine and the remote SSH2 server. Read through the host key whitepaper for more information about why validation of host keys is crucial to your security.

If you're not really concerned about security, then you can choose to implement the "/ACCEPTHOSTKEYS" option when calling Connect() as described in the SecureCRT help (see the topic titled "Table of Protocol-Specific Command-Line Options") as well as made mention of in this other forum post.

SecureCRT 8.0 adds a globally-applied advanced option which you can enable if you want SecureCRT to blindly trust all hosts without ever prompting to verify any host keys. Enabling such an option disavows adherence to best practice, but if this approach is a must-have for your situation, please send email to support@vandyke.com with a subject of "Forum #10651: Globally-applied Accept Host Keys Option?"

--Jake
__________________
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
  #103  
Old 07-24-2016, 06:57 PM
Zackz Zackz is offline
Registered User
 
Join Date: Jul 2016
Posts: 1
Hi all

I am experiencing an issue with the vb script to log the full data output to individual files. Whenever I tried to run a command with long output like "show int status", I would have to manually hit the spacebar to let the script continue running.

What are the changes required on the script to let it run automatically towards the end? Btw I am using SecureCRT v8 and working on Cisco devices. Thanks in advance.
Reply With Quote
  #104  
Old 07-25-2016, 08:27 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 3,945
Hi Zackz,

If you send the command term len 0 to the remote, it should disable the --More-- prompts. That's illustrated around line 183 of this example Python script.

If your device does not support the term len 0 command, then you will have to handle the prompt similar to what's shown below:

Code:
    ' Wait for either the shell prompt to appear or the
    ' "--More--" prompt to appear. If the shell prompt
    ' appears, we know that there isn't any more
    ' "--More--"'s to worry about, so we'll exit the loop.
    Do
        nStringIndex = objTab.Screen.WaitForStrings("]$", "--More--", 30)
        Select Case nStringIndex
            Case 0
                ' Timed out after 30 seconds waiting for either string.
                ' Since we expect a screen-full of data to come within
                ' 30 seconds, if nothing appears we'll just exit the
                ' loop
                Exit Do

            Case 1
                ' Shell prompt was found... exit 'do' loop
                Exit Do

            Case 2
                ' We found a "--More--" prompt.
                    objTab.Screen.Send " "
        End Select
    Loop
If your goal is to not have those prompts appear in your log data, you would have to expand on the above code to "erase" the output (taken from another example script):

There could be an additional/different possibility in the WaitForStrings() call:

Code:
    strMorePromptErasure = _
        String(9, chr(8)) & String(8, " ") & String(9, chr(8))
And a new Case for handling:

Code:
                Case strMorePromptErasure
                    ' Cisco switches/routers display the --More-- prompt and then
                    ' to get rid of it, they spew backspaces to move the cursor
                    ' to the left, then they spew spaces (8 of them) to "erase"
                    ' the "--More-- " text, then they spew 9 more BS chars to
                    ' move the cursor back to the start of the line.
                    ' This case is simply a no-op... just a way to get rid of
                    ' the BSBSBSBSBSBSBSBSBSBS        BSBSBSBSBSBSBSBSBSBS
                    ' that would show up in the strData if we didn't do this.
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #105  
Old 11-23-2016, 04:29 AM
netsecrets00 netsecrets00 is offline
Registered User
 
Join Date: Jul 2015
Posts: 10
Quote:
Originally Posted by rtb View Post
Demonstrates how to connect to hosts read in from a "hosts" file and for each host, send a list of commands read in from a "commands" file. Results of each command run are (by default) logged to separate, uniquely-named files based on the host address and the command that is run. However, the script code is architected to allow you to change this behavior so that it's all logged to one file per host, or even just to a single file.

The old version of the script is named "ReadDataFromHostFile-SendCommandsFromCommandsFile-LogResultsTo...". These versions are now deprecated, but are the only Python versions currently available.

The new version of the script (July, 2016) is named "RunCommandsOnMultipleHostsAndLogResults".

.
How do I use new script from Jumpserver ? Because I am already connected, I am getting error Already Connected.
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 10:49 PM.