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 11-19-2020, 10:15 AM
mohenoun mohenoun is offline
Registered User
 
Join Date: Nov 2020
Posts: 21
Trying to tweak the script to no avail

Hello,

I'm really new to scripting.

I have to audit several equipment by sending a command line.

However, I'm not able to use the script.

Forum Moderator:
[Referenced script is here.]

To connect to an equipment I need to connect to a rebound server which I can easly do if I use :

def main():
crt.Session.Connect("/s name of the session")

main()


Then I have to connect to the quipment using the specific command :

ssh -l <Myusername> <IPaddress>

then I get prompted to enter a password.

I tried to tweak the script so that I could use it with this constraints, however it doesn't work.

I was wondering if a charitable soul could help me.

Thank you in advance.

Last edited by bgagnon; 12-01-2020 at 11:55 AM. Reason: Added reference to script in another post.
Reply With Quote
  #2  
Old 11-19-2020, 10:46 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,544
Hi mohenoun,

First, please clarify if by "the script", you were referencing sranbala's posted script here?

Or VanDyke's Read Data example script that was referenced in the thread?

By "rebound server", it sounds like you are going through a jump host. If the jump host is capable of port forwarding, I would recommend you make the connection using SecureCRT's dependent session feature.
__________________
Thanks,
--Brenda

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

First, please clarify if by "the script", you were referencing sranbala's posted script here?

Or VanDyke's Read Data example script that was referenced in the thread?

By "rebound server", it sounds like you are going through a jump host. If the jump host is capable of port forwarding, I would recommend you make the connection using SecureCRT's dependent session feature.
Hello,

Sorry my question wasn't clear.

I'll try to structure it more

Context :
=========

I have to do an audit in my company for several cisco equipments, my idea was to launch a script in order to be able to do it automatically while going through a list of Ips vs commands.

Constraint :
------------

To connect to equipment I need to connect to a rebound equipment. Basically if I wanted to connect to equipment A, in scripting it would be :

crt.Session.Connect("/s rebound.win")
crt.Screen.Send "ssh -l userid " & equipment A & chr(13)
crt.Screen.WaitForString "Password:"
crt.Screen.Send "Mypassword" & chr(13)
crt.Screen.WaitForString "#"
crt.Screen.Send chr(13)
crt.Screen.Send "show ip bgp vpnv4 all summ | inc Idle" & chr(13)
crt.Screen.Send "exit" & chr(13)

Then connect again with
crt.Screen.Send "ssh -l userid " & equipment B & chr(13)
crt.Screen.WaitForString "Password:"
crt.Screen.Send "Mypassword" & chr(13)
crt.Screen.WaitForString "#"
crt.Screen.Send chr(13)
crt.Screen.Send "show ip bgp vpnv4 all summ | inc Idle" & chr(13)
crt.Screen.Send "exit" & chr(13)

If I keep my session in the rebound.

If I open in different tabs I just use :

crt.Session.Connect("/s rebound.win")
crt.Screen.Send "ssh -l userid " & equipment A & chr(13)
crt.Screen.WaitForString "Password:"
crt.Screen.Send "Mypassword" & chr(13)
crt.Screen.WaitForString "#"
crt.Screen.Send chr(13)
crt.Screen.Send "show ip bgp vpnv4 all summ | inc Idle" & chr(13)
crt.Screen.Send "exit" & chr(13)

And I log the session.

This is how I'm doing it right now archaically ! Because my coding is limited.

Script:
========

I found this on the website :https://forums.vandyke.com/showpost....94&postcount=1

RunCommandsOnMultipleHostsAndLogResults.vbs.txt

Need:
=====

I want to modify the script so that it connects the way I need to connect and the runs the commands using the hosts and commands files.


I hope it is clear

Thank you.
Reply With Quote
  #4  
Old 11-20-2020, 10:10 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,544
Hi mohenoun,

Did you read the information about dependent session?

Are you unable (jump server does not support port forwarding) to use this feature? Or just unwilling to try it?

It's going to simplify things before we get into your actual script, which, by the way, includes multiple Send() calls without an intervening WaitForString().

This goes against the "best practice" outlined in the scripting manual (section 4.2) that there should be a WaitForString() following each Send() command.
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #5  
Old 11-20-2020, 11:36 AM
mohenoun mohenoun is offline
Registered User
 
Join Date: Nov 2020
Posts: 21
I canít forward

Quote:
Originally Posted by bgagnon View Post
Hi mohenoun,

Did you read the information about dependent session?

Are you unable (jump server does not support port forwarding) to use this feature? Or just unwilling to try it?

It's going to simplify things before we get into your actual script, which, by the way, includes multiple Send() calls without an intervening WaitForString().

Hello Brenda,

This goes against the "best practice" outlined in the scripting manual (section 4.2) that there should be a WaitForString() following each Send() command.
I canít port forward unfortunatelly. I work for a bank and Iím quite limited in my options.

I just put forward the script as an exemple, Iím really new to this. Thus I wanted to use a script that was following best practices. But I got lost in the coding and couldnít figure out what to change and where and how to do it in a clean way.

Thank you for your help.
Reply With Quote
  #6  
Old 11-20-2020, 12:41 PM
mohenoun mohenoun is offline
Registered User
 
Join Date: Nov 2020
Posts: 21
Actually, I just want to know what to change in https://forums.vandyke.com/showpost....94&postcount=1

Since my jump server doesn't seem to allow port forwarding.
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 10:02 PM.