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-09-2013, 09:42 AM
mikit mikit is offline
Registered User
 
Join Date: Mar 2012
Posts: 38
set number of columns when session starts

Hello,

I am trying to get some information from several devices. Problem is, that everytime script connects to new device, session is resized back to 80 columns. This is causing a problem, because output that should be on one line is sometimes splited to two lines and sometimes it remains in one line.

Here is an example:

crt.Screen.Send "sh ver | i of memory" & VbCr
crt.Screen.WaitForString "#"
modelStr = crt.Screen.Get(crt.Screen.CurrentRow-1, 1, crt.Screen.CurrentRow-1, 50)
model = split(modelStr, " ")

hostname#sh ver | i of memory
Output from which I get device model (numbers of characters varies)
hostname#

So it is simple, I'll wait for the # chr and then read one line above to get the info I need. But as lenght of output varies, sometimes it looks like:

hostname#sh ver | i of memory
Output from which I get device model (numbers of characters var
ies)
hostname#

and in this case script reads only "ies)" which do not contain info I need.

Is it possible to use some command in vbs to set number of columns every time I connect to a device?
Reply With Quote
  #2  
Old 01-09-2013, 10:23 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,046
Hello mikit,

What version of SecureCRT are you using?

Quote:
Is it possible to use some command in vbs to set number of columns every time I connect to a device?
The simple answer to the above question is yes, as of SecureCRT 6.x the SessionConfiguration object was added. The GetOption/SetOption methods available to this object allow you to obtain/change options that are provided via the session .ini files.

If using a version that includes these scripting methods, the SecureCRT Help topic Scripting / Script Objects Reference / SessionConfiguration Object includes additional information on syntax.

However, I would like to get a bit of additional information on what you are trying to accomplish as I think there might be better ways to approach this task.

For example, you might use ReadString() instead of Get() to obtain the information needed.

How are you connecting to the devices (ie: via saved sessions or ad hoc connections)?
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #3  
Old 01-09-2013, 10:49 AM
mikit mikit is offline
Registered User
 
Join Date: Mar 2012
Posts: 38
Thank you Brenda for your response.

I am using v6.5

Anyway, as you mentioned ini file, I've opened default.ini and changed:

D:"Rows"=00000018
D:"Cols"=00000050

to

D:"Rows"=00000018
D:"Cols"=00000064

Now anytime I open a secure crt I have 100 columns.

But I will try to use readstring instead of get to see if it works too.
Reply With Quote
  #4  
Old 01-09-2013, 11:56 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,046
Hi mikit,

Quote:
D:"Rows"=00000018
D:"Cols"=00000050

to

D:"Rows"=00000018
D:"Cols"=00000064

Now anytime I open a secure crt I have 100 columns.
I assume it was just a typo, but it seems strange for you to get 100 columns if you set columns to 64 in the Default.ini file.

You took a different approach, but as long as it resolves the issue.

Here's an example of how rows/columns could be set via a script:

Code:
' This will use the default configuration file
Set objConfig = crt.Session.Config

' Set rows
objConfig.SetOption "Rows",40

' Set columns
objConfig.SetOption "Cols",100
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #5  
Old 01-09-2013, 12:10 PM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,046
Hi mikit,

Ignore this comment, please:

Quote:
I assume it was just a typo, but it seems strange for you to get 100 columns if you set columns to 64 in the Default.ini file.
I forgot this was a hexadecimal value in the .ini file.
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #6  
Old 01-09-2013, 12:11 PM
mikit mikit is offline
Registered User
 
Join Date: Mar 2012
Posts: 38
It is not a typo. I do not know why, but i had to put 64 there to get 100 columns

Iw will try objConfig.SetOption and see if it works :-)

Thank you.
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:36 PM.