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 09-26-2018, 10:02 PM
metallicat metallicat is offline
Registered User
 
Join Date: Sep 2017
Posts: 22
Default session opens when script run on an empty window

Hi,

I'm writing a script that's supposed to open the same bastion (jumpbox) session (stored in the session manager) several times and connect to different devices from there.

The code looks something like that:
Code:
def connect_to_bunch():
	target = crt.Dialog.Prompt("Enter target:")
	user = crt.Dialog.Prompt("Enter username:")
	bastion_name = 'blabla'
	bastion = '"{}"'.format(bastion_name)
	devices = unpack_devices(target)
	for device in devices:
		tab = crt.Session.ConnectInTab("/S {}".format(bastion), True)
		crt.Sleep(5000)
		crt.Screen.WaitForStrings(["#", "%"], 5)
		crt.Screen.Send("ssh {}@{}".format(user, device))
The end goal is to have several session open simultaneously so that I can work with them using the command window. When I run this script on an empty window (no tabs open) then right at the beginning a default session opens (not the jumpbox session that's requested inside the for loop).

It seems as though no script can be run without an open session.
Is that actually the case? Can it be circumvented in any way?
Reply With Quote
  #2  
Old 09-27-2018, 08:20 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 3,557
Hi metallicat,

I am not sure what you are reporting. It works as expected for me, but of course you've only posted part of your script.

Also, there was a '\r' I needed to add on the "ssh send":
crt.Screen.Send("ssh {}@{}".format(user, device) + "\r")
What version of SecureCRT are you using?

On what platform?

What does your unpack_devices function do?

Have you seen our example JumpHost script in the forums here?
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
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 04:35 PM.