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-09-2008, 10:20 AM
bsachnoff bsachnoff is offline
Registered User
 
Join Date: Sep 2008
Posts: 8
Gathering session name

How can I read the "session name"? This is the same as %S in the logging options.

Thanks,
Brent
Reply With Quote
  #2  
Old 09-10-2008, 07:45 AM
tnygren's Avatar
tnygren tnygren is offline
Registered User
 
Join Date: May 2005
Posts: 1,408
Hi Brent,

There is a scripting object that will return the path to the session relative to the main 'Sessions' folder.

This is the same information returned when '%S'.

The scripting object is:
CRT.Session.Path
Was this the information needed?
__________________
Thanks,

Teresa

Teresa Nygren
Reply With Quote
  #3  
Old 12-15-2008, 12:08 PM
bsachnoff bsachnoff is offline
Registered User
 
Join Date: Sep 2008
Posts: 8
My apologizes for the long delay in getting back. The .Path is too much info. I really only want the session name. My main purpose is because I ssh into jump boxes before ending up in the box I was trying to get to and I need to log all of my sessions.

I know I can do this by using the automated login process but with the amount of jump boxes and networks it is very tedious to set up. With the ability to find out the hostname within the script, I can have a single script to use. Quick example:

ssh to jumbox01. After login, enable logging for the session name (mainrouter01 and call it %Y%M%D.%S.%h%m.log). SSH into mainrouter01 and continue to log until session ends.

My current work around is to get the %S using crt.Session.LogFileName and storing it in a varible. I then reset the logfilename to %Y%M%D.%S.%h%m.log. Next I send my ssh command with the varible declared above. Although this works too, it does seem to run into problems on occassion.

Thanks for the reply!

Brent
Reply With Quote
  #4  
Old 12-15-2008, 03:50 PM
kbarnette kbarnette is offline
VanDyke Technical Support
 
Join Date: Aug 2007
Posts: 587
Hi bsachnoff,

The .Path property can still be used to determine the session path, thus negating the need to set your log file and then set it back to the original.

An example of how one would extract the session name from the .Path property is below:

Code:
Do

    nSlashLoc = Instr(MySessionPath, "\")
    if nSlashLoc = 0 then exit Do
    
    MySessionPath = Right(MySessionPath, Len(MySessionPath) - nSlashLoc)
    MsgBox MySessionPath

Loop

MsgBox "Final Session Path: " & MySessionPath
Such script code would iterate through the path, grabbing the part of the string to the right of the first '\' character, until it doesn't find a '\' character in the string.

Using this information, are you able to extract the session name from the .Path property?
Reply With Quote
  #5  
Old 12-15-2008, 04:33 PM
bsachnoff bsachnoff is offline
Registered User
 
Join Date: Sep 2008
Posts: 8
That worked great! Thanks for taking the time kbarnette.

Brent
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 09:37 PM.