Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Reply
 
Thread Tools Rate Thread Display Modes
  #136  
Old 10-05-2018, 09:12 AM
ekoranyi ekoranyi is offline
VanDyke Technical Support
 
Join Date: Jan 2017
Posts: 595
Hi JYOTIRANJAN,

I received your email and have responded. I look forward to working with you.
__________________
Thanks,
--Eric

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #137  
Old 10-25-2018, 06:31 PM
Dagrin Dagrin is offline
Registered User
 
Join Date: Oct 2018
Posts: 1
Question Issues Executing Script - Separate Hosts/Commands File and Log to Individual Files

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.

Download the example scripts:
Python Version (for use on Mac/Linux versions of SecureCRT):
RunCommandsOnMultipleHostsAndLogResults.py.txt
Last updated: 21 May, 2018 (initial revision)

VBScript Version (for use on Windows versions of SecureCRT):
RunCommandsOnMultipleHostsAndLogResults.vbs.txt
Last updated: 21 May, 2018

Example ##hosts.txt and ##commands.txt files:
The following show you the format of what the ##hosts.txt and ##commands.txt files would look like.The ##hosts.txt file can contain host-specific command file directives, which is what the ##DeviceType1Commands.txt and ##DeviceType2Commands.txt files exemplify.



.
I downloaded the example script mentioned above and I am able to have it execute the host list. I am using the script to connect to multiple Cisco routers and need it to enter configuration mode. The commands.txt file executes the first few lines as expected, but after executing "configure" the script hangs. I suspect that it is hanging because the prompt changes from # to (config)#. I cannot find the location in the script that forces the script to only continue after seeing the prompt of # to return. I need to change that to allow the continuance if the changed prompt occurs. Any advice?
Reply With Quote
  #138  
Old 10-25-2018, 07:00 PM
jdev's Avatar
jdev jdev is offline
VanDyke Technical Support
 
Join Date: Nov 2003
Location: Albuquerque, NM
Posts: 858
Quote:
Originally Posted by Dagrin View Post
I downloaded the example script mentioned above and I am able to have it execute the host list. I am using the script to connect to multiple Cisco routers and need it to enter configuration mode. The commands.txt file executes the first few lines as expected, but after executing "configure" the script hangs. I suspect that it is hanging because the prompt changes from # to (config)#. I cannot find the location in the script that forces the script to only continue after seeing the prompt of # to return. I need to change that to allow the continuance if the changed prompt occurs. Any advice?
The script is designed to expect the same shell prompt throughout the course of all the commands that are run.

If you choose Script > Cancel when the script is running and in its "hung" state, you'll see a message indicating which line of code the script was on when you canceled execution, and it will most likely lead you to the line of code you need to modify.

In all likelihood, it's this one near line #482 in the script:
Code:
strResult = g_objNewTab.Screen.ReadString(strPrompt)
If you desire to have it continue if it finds either the actual shell prompt or the tailing end of any sub-prompt, you can probably get away with this:
Code:
strResult = g_objNewTab.Screen.ReadString(strPrompt, ")#")
That work for you?

--Jake
__________________
Jake Devenport
VanDyke Software
Technical Support
YouTube Channel: http://www.youtube.com/vandykesoftware
Email: support@vandyke.com
Web: http://www.vandyke.com/support
Reply With Quote
  #139  
Old 11-19-2018, 09:54 PM
NetMerc NetMerc is offline
Registered User
 
Join Date: Nov 2018
Posts: 3
Replace IP Address with Hostname in the log file

Quote:
Originally Posted by rtb View Post
Hi hvh2000,

Thanks for the post. It seems like you are using the VBScript version. If I am wrong, please correct me because the log file code is different between the VBScript and Python versions.

In the VBScript code starting on line 257, the IPADDRESS portion of the template name gets replaced with the IP address (g_objNewTab.Session.RemoteAddress). Line 260 could be modified to use g_strhost which is obtained on line 136 from the host file.

Does this help you accomplish your goal?
Hello - I apologize for the repeat question regarding replacing IPADDRESS with the hostname in the logfile.

I am relatively new to VB scripting.
I am using the v8.5 of SecureCRT and the most recent version of the script (as of 2018-11-18).

The line number references no longer match the quoted post above and I am rather lost.

My goal is for the logfile to be saved as:
HOSTNAME-YYYY-MM-DD--hh'mm'ss.txt"

Thank you in advance -

Max Dixon
Reply With Quote
  #140  
Old 11-20-2018, 08:42 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 3,652
Hi NetMerc,

It happens, that post was from August 2008. As you can see from the script comments, tons of functionality has been added to the script since then.

Are you going to want to log to individual files per host?

Or just one file for all the hosts?
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #141  
Old 11-20-2018, 08:49 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 3,652
Hi Max,

Sorry, that was probably a dumb question on my part if you want HOSTNAME to be used in the log filename.

I assume it's individual log files then.

A few more inquiries though. Are you just using the basic functionality? Meaning you have a ##hosts.txt file that contains the hosts you want to connect to? (You are not using already connected sessions?)
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #142  
Old 11-21-2018, 07:11 AM
NetMerc NetMerc is offline
Registered User
 
Join Date: Nov 2018
Posts: 3
Quote:
Originally Posted by bgagnon View Post
Hi Max,

Sorry, that was probably a dumb question on my part if you want HOSTNAME to be used in the log filename.

I assume it's individual log files then.

A few more inquiries though. Are you just using the basic functionality? Meaning you have a ##hosts.txt file that contains the hosts you want to connect to? (You are not using already connected sessions?)
No problem! Thank you for the response.

Yes, my host file has a series of hosts such as
s00123.hostname.com
s00456.hostname.com
s00789.hostname.com

Thank you for your assistance.

- Max Dixon
Reply With Quote
  #143  
Old 11-21-2018, 09:40 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 3,652
Hi Max,

These are the changes I would suggest to the current script to accomplish your objective (as I understand it):
  • Change boolean to True on line 147 (enabling logging to individual files per host)

  • Replace lines 171 and 173 with your credentials

  • Replace three instances of g_objNewTab.Session.RemoteAddress with g_strHost on lines 529, 532 and 533

  • Remove ALLCMDS on line 558, leaving it empty:
strLogFile = Replace(strLogFile, "COMMAND", "")
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #144  
Old 11-22-2018, 04:32 PM
NetMerc NetMerc is offline
Registered User
 
Join Date: Nov 2018
Posts: 3
Quote:
Originally Posted by bgagnon View Post
Hi Max,

These are the changes I would suggest to the current script to accomplish your objective (as I understand it):
  • Change boolean to True on line 147 (enabling logging to individual files per host)

  • Replace lines 171 and 173 with your credentials

  • Replace three instances of g_objNewTab.Session.RemoteAddress with g_strHost on lines 529, 532 and 533

  • Remove ALLCMDS on line 558, leaving it empty:
strLogFile = Replace(strLogFile, "COMMAND", "")
That did the trick. Thank you!
Reply With Quote
  #145  
Old 11-25-2018, 12:55 PM
iabudi iabudi is offline
Registered User
 
Join Date: Oct 2014
Posts: 4
Script doe not proceed after the first command

Script doe not proceed after the first command

I am using ScureCRT version 7.2.6

I am testing different commands in Juniper

if I use this command
"show configuration system login | display set"
it work well and If there are long replies I have to manually enter the space key to finish the output.

if I use this command
"show configuration system login | display set |no-more"
I get the complete output of the first node but it Just stops at the prompt and it do not continue.
Reply With Quote
  #146  
Old 11-26-2018, 08:53 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 3,652
Hi iabudi,

Is Cancel available in the Script menu?

If so and you select it, what is the error?
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #147  
Old 12-29-2018, 07:58 AM
Elisha Elisha is offline
Registered User
 
Join Date: Dec 2018
Posts: 1
Question RunCommandsOnMultipleHostsAndLogResults.vbs.txt line:665 error

i try to run this scripting on my PC, but i can not running on W10,
may i know what wrong on my PC, what should i change to use this script.


line 665 error:
whit this message:

microsoft VBscript runtime error
Error: Wrong number of arguments of invaild property assignment:
'crt.Session.ConnectinTab'
file: C:\user\Elisha\Documnets\RunCommandsOnMultipleHostAndLogResult.vbs
line:665
Reply With Quote
  #148  
Old 12-29-2018, 04:00 PM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 3,652
Hi Elisha,

That error/line combination does not really correlate to the latest version of the script.

Where did you get your copy of the script?

Did you make any changes to it?

The latest version is this May 21, 2018 script example in post #1 of this thread.
__________________
Thanks,
--Brenda

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

Last edited by bgagnon; 12-29-2018 at 04:00 PM. Reason: Added exact date
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 07:30 PM.