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 05-11-2019, 03:18 PM
ashehata ashehata is offline
Registered User
 
Join Date: Aug 2017
Posts: 13
Log Multiple Sessions Option

Hello Guys,

I have the "Log Multiple Sessions option" in the default session enabled, in order to log multiple sessions in the same file but when I run a script that modifies the filename, the log Multiple session option seems disabled and it gets multiple files for the same tab instead of one file.

Code:
tab.Session.LogFileName = 'C:\\Users\\<Hidden>\\Desktop\\LOGS\\' + CurrentDay +"\\"+ Device_name + ".log
I thought that it uses the default session when I use the above command but it seems another session with the log multiple sessions option disabled, please correct me if I am wrong?

Is there any option to enable this feature within the script or something to do it to fix it?


Note: I have done a workaround to solve it by using a predefined session instead of using the below command.

Code:
tab = crt.Session.ConnectInTab('/ssh2 /L '+ username +  ' /PASSWORD ' + password + '  < IP address>')"


Best Regards,
Ahmed Shehata

Last edited by ashehata; 05-11-2019 at 03:23 PM.
Reply With Quote
  #2  
Old 05-12-2019, 05:30 PM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 3,894
Hi Ahmed,

I am not sure I understand the issue.

The Default Session is what is used when you make an ad hoc connection.

So are you saying you are then trying to write to the same file in another ad hoc session?

Please list the explicit steps to replicate the issue.
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #3  
Old 05-13-2019, 02:44 AM
ashehata ashehata is offline
Registered User
 
Join Date: Aug 2017
Posts: 13
Hello bgagnon,

Thanks to check my below code to make it clear.

Code:
# $language = "python"
# $interface = "1.0"

import time

def main():
  
  
  #User Credential
  
  username = "Removed"
  password = "Removed"
  CurrentDay = time.strftime("%d-%m-%Y")
 

  Device_name = crt.Dialog.Prompt("Please Enter The Device Name:", "Quick Connect Menu", "")


  if Device_name  == '':
    return

  

# SSH2 to a Server

  tab = crt.Session.ConnectInTab('/ssh2 /L '+ username +  ' /PASSWORD ' + password + ' Server')



  #Tab Synchronization
  tab.Activate()
  tab.Screen.Synchronous = True


  # Set the tab name
  tab.Caption = Device_name

  # Log file path 
  tab.Session.LogFileName = 'C:\\Users\\XDXT6361\\Desktop\\LOGS\\' + CurrentDay +"\\"+ Device_name + ".log"
  


               

  # Accessing a device 
  tab.Screen.WaitForString("password: ")
  tab.Screen.Send( password + '\n')
  tab.Screen.WaitForString("#")
  tab.Screen.Send("l" + ' ' + Device_name  + '\n')


main()
So let's say that I am going to connect to router X then I will connect again to the same router X. So I have 2 tabs connected to the same router. What happenes is that I have two files created. First file named X.log and the second file named X_1.log..

What I would like to do is to have only one file for the same device without creating different log files when I have multiple tabs for the same device

Note: According to my script, the log file name will be created according to the device name being connected to.


By the way, I have found that the command that is used to enable the"Log Multiple Sessions option" but it didn't work from first time, until I have done some extra commands.

Code:
  Config = crt.Session.Config
  Config.SetOption("Log Multiple Sessions", 1)
  tab.Session.LogFileName = 'C:\\Users\\XDXT6361\\Desktop\\LOGS\\' + CurrentDay +"\\"+ Device_name + ".log"
  tab.Session.Log(False)
  tab.Screen.SendSpecial("MENU_LOG_SESSION")
So I am still wonder why it didn't work since it's using the default session and it has to be enabled in the configuration..

It also didn't work when I used "Config.SetOption("Log Multiple Sessions", 1)" and I had to toggle the log option off and on again.

I hope this made everthing clear and don't hesitate if anything is still not clear yet.

Best Regards,
Ahmed Shehata
Reply With Quote
  #4  
Old 05-13-2019, 09:38 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 3,894
Hi Ahmed,

It sounds like you have a related option enabled that needs disabled:

D:"Generate Unique Log File Name When File In Use"=00000001

If you add the following to your script, what are the results?

Config.SetOption("Generate Unique Log File Name When File In Use", 0)
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #5  
Old 05-17-2019, 09:36 AM
ashehata ashehata is offline
Registered User
 
Join Date: Aug 2017
Posts: 13
Hello Brenda,

I have added "Config.SetOption("Generate Unique Log File Name When File In Use", 0)" but it didn't solve the issue but I have managed to solve it by removing the below commands and I only toggle the session log off and on after modifying the Logfilename.

Removed the below part from the script:
Code:
  Config = crt.Session.Config
  Config.SetOption("Log Multiple Sessions", 1)

The final logging part from the script:
Code:
 
  tab.Session.LogFileName = 'C:\\Users\\XDXT6361\\Desktop\\LOGS\\' + CurrentDay +"\\"+ Device_name + ".log"
  tab.Session.Log(False)
  tab.Screen.SendSpecial("MENU_LOG_SESSION")
Thanks a lot Brenda for your support and assistance.

Best Regards,
Ahmed Shehata

Last edited by ashehata; 05-17-2019 at 09:39 AM.
Reply With Quote
  #6  
Old 05-17-2019, 01:24 PM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 3,894
Hi ashehata,

Thanks for posting an update.
__________________
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 08:18 PM.