|
#1
|
|||
|
|||
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: 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. |
#2
|
|||
|
|||
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 |
#3
|
|||
|
|||
Quote:
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. |
#4
|
|||
|
|||
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 |
#5
|
|||
|
|||
I can’t forward
Quote:
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. |
#6
|
|||
|
|||
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. |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Display Modes | Rate This Thread |
|
|