Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 01-03-2007, 07:52 AM
tatster tatster is offline
Registered User
 
Join Date: Aug 2006
Posts: 10
Send a message via MSN to tatster
Looking for Scripting advice!!

Hi,

Sorry if this is a bit of a long post - trying to explain myself clearly!!!

I am putting together a script to get config backups from various Cisco devices in my network.
Firstly, I am getting the config by writing to logfiles on my local machines. I am doing this because, for various reasons using TFTP is not an option to me.

I am reading the device IP addresses in from a CSV and then hoping to loop through the CSV, connecting to each device, sending a show running and capturing that to a separate log file.

Now, I have got part way through getting the script to work but I need a bit of advice please!
I need this to work by making a telnet connection to a management unix box, and then doing the telnet to the devices from that mgmt station.
Option 1) make individual connections to the mgmt station, and device, then disconnect and use the
Code:
If ( objse.connected ) Then
statements. This obviously means making lots of connects/disconnects from the mgmt station.
Option 2) Make one connection to the mgmt box, and do the loop around. This seems to me to be the better option but I'm unsure how to do this bit.

All suggestions on a postcard please!

Many thanks in advance.

Anthony
Reply With Quote
  #2  
Old 01-03-2007, 11:40 AM
tnygren's Avatar
tnygren tnygren is offline
Registered User
 
Join Date: May 2005
Posts: 1,408
Hi Anthony,

I agree that the best option from what you describe would be to use a loop to connect to each of the hosts after making the connection to the Unix management box.

I would first read in the CSV text file and place the contents into an array. A simple example of this would be in the 'ReadDataFromFile.txt' example script that I have attached.

ReadDataFromFile.txt

Once in the array, a do loop can be created to parse through that array and connect to each of the routers to send commands. This can be done with the crt.screen.send object.

For example, if the array set the szIP variable to the next IP entry, the command would look like:

crt.screen.send "telnet " & szIP & vbcr

There are several ways to handle looping through the array to issue the command.

This is an example script showing how to read a file for session names and then connect to each of those sessions to issue commands.

ConnectToMultipleSessionsAndSendCommands.txt

Does this help?
__________________
Thanks,

Teresa

Teresa Nygren
Reply With Quote
  #3  
Old 01-04-2007, 08:27 AM
tatster tatster is offline
Registered User
 
Join Date: Aug 2006
Posts: 10
Send a message via MSN to tatster
Hi Teresa,

Thanks for your reply.

I think I know how I will do the connections from the mgmt box now.
However I was reworking some of the script and noticed that it doesn't appear to be picking up the line that sets the log file name.
I have the line:
Code:
objse.logfilename = Logfiles&"\"&IP&".Log"
in the script but when I run the script it still uses the log path that is set in my global options, which is set to C:\Documents and Settings\awarren\My Documents\logs\%S - %H - %Y%M%D-%h-session.log

Is this correct operation? Running version 5.2.0 (build 229) I have attached the script in its current form for reference. (Line 101 is where I think it should set the log file name.

Many thanks,
Anthony
Attached Files
File Type: txt Get_ROUTER_CFG2.txt (3.9 KB, 255 views)
Reply With Quote
  #4  
Old 01-04-2007, 12:36 PM
tnygren's Avatar
tnygren tnygren is offline
Registered User
 
Join Date: May 2005
Posts: 1,408
Hi Anthony,

In reading your description, it appears that logging may already be enabled for the connection.

If this is the case, then you will not be able to change the log file being used until logging is disabled.

SecureCRT 5.2 does have a new scripting object called 'crt.session.logging' which will return a Boolean value to indicate if logging is enabled or not.

Using this object, you could modify the script so that if logging is enabled, then the script could stop logging, set the new log file and then start logging again.

If it was not logging, then the script could just set the log file name and start logging.

Using the 'crt.session.logging' would cover both cases.

Does using something like this in the script allow the correct log file name to be used?
__________________
Thanks,

Teresa

Teresa Nygren
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 -6. The time now is 02:44 AM.