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 04-17-2020, 08:14 AM
dahaboz dahaboz is offline
Registered User
 
Join Date: Apr 2020
Posts: 7
scripting issue

Dear:
I modified this script and it works great, the only issue is it doesn't save the first log file and neglect it, can I get your support.

Thanks on advance
======================================================================
Code:
# $language = "VBScript"
# $interface = "1.0"
' SendToAll.vbs

Sub Main()
    crt.Session.Connect "/s DPI_SPB_CC"
    if Not crt.Session.Connected then
        szSession = crt.Dialog.Prompt("Enter session:", "", "", False)
        if szSession = "" then exit sub
        crt.Session.ConnectInTab("/S DPI_SPB_CC" & szSession)
    end if

    arrCommands = Array("chronyc sources -v", "show alarms all", "show alarms history")

    ' Send commands to all tabs
    ' Connect to each tab in order from left to right, issue all commands, and
    ' then disconnect...
    ' crt.Session.Log True
    For nIndex = 1 to crt.GetTabCount
        Set objCurrentTab = crt.GetTab(nIndex)
        objCurrentTab.Activate

        If objCurrentTab.Session.Connected = true Then
            crt.Session.LogFileName = szSession

            For Each strCommand In arrCommands
                crt.Sleep 500
                objCurrentTab.Screen.Send strCommand & vbcrlf
                ' objCurrentTab.Screen.WaitForString strCommand & vbcr
                crt.Sleep 1000
            Next
            ' objCurrentTab.Session.Log False
        End If
    Next
End Sub

Last edited by bgagnon; 04-17-2020 at 09:27 AM. Reason: Tidied up code
Reply With Quote
  #2  
Old 04-17-2020, 09:30 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,322
Hi dahaboz,

I don't quite understand your setup. You are connecting only to one session in the script. Do you expect to have other connections open in tabs before running the script?

Did you configure logging in that one session (DPI_SPB_CC)? Because you have commented out where you enabled logging in the script.

What are you trying to accomplish?
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #3  
Old 04-27-2020, 06:12 AM
dahaboz dahaboz is offline
Registered User
 
Join Date: Apr 2020
Posts: 7
Dear Bgagnon,

I pre-configured the session to open in tabs when I run the script. and it automatically opened the tabs one by one as i have more than 16 (DPI_SPB) node.

When I import the sessions and run the script it saves the logs in the directory as I expected, but if disconnect from the session and try to reopen it send to me a save as dialog for the sessions, and it ignores only the first tab to be saved on the logs and other tabs be saved in the same directory, only the first tab missed from the logs.

Hopefully, I explained the situation, and you get my point, and deeply sorry for the delay.

Best regards
Reply With Quote
  #4  
Old 04-27-2020, 08:26 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,322
Hi dahaboz,
Quote:
When I import the sessions and run the script it saves the logs in the directory as I expected, but if disconnect from the session and try to reopen it send to me a save as dialog for the sessions, and it ignores only the first tab to be saved on the logs and other tabs be saved in the same directory, only the first tab missed from the logs.
I need more specific info with respect to the above issues.

If these are saved sessions, is Prompt for filename enabled in the Terminal / Emulation / Log File category of Session Options? Is Append to file enabled?

Where are the logs being saved? What NTFS permissions does the folder/files have?
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730

Last edited by bgagnon; 04-27-2020 at 08:29 AM. Reason: Additional question
Reply With Quote
  #5  
Old 04-27-2020, 10:51 AM
dahaboz dahaboz is offline
Registered User
 
Join Date: Apr 2020
Posts: 7
Dear Bgagnon,

responding to your questions

1- If these are saved sessions? yes it's saved session

2- is Prompt for filename enabled in the Terminal / Emulation / Log File category of Session Options? No, and should I enable it.


3- Is Append to file enabled? yes


4- Where are the logs being saved? saved in the D directory ((d:\SecurCRT logs\%Y-%M-%D\(%H)--%h%m.log)

5- What NTFS permissions does the folder/files have? I am not sure about that and is it makes a difference?

Best regards
Reply With Quote
  #6  
Old 04-27-2020, 11:03 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,322
Hi dahaboz,
Quote:
4- Where are the logs being saved? saved in the D directory ((d:\SecurCRT logs\%Y-%M-%D\(%H)--%h%m.log)
That's likely the issue. When you connect again, is it the exact same hour and minute? If not, then it cannot append to the existing file and is prompting you to specify another.
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730

Last edited by bgagnon; 04-27-2020 at 02:40 PM. Reason: TYPO!!
Reply With Quote
  #7  
Old 04-27-2020, 01:17 PM
dahaboz dahaboz is offline
Registered User
 
Join Date: Apr 2020
Posts: 7
Dear Bgagnon,

when I delete hour and minute (%h%m) it makes the change and then the save as didn't come, but it saves only one log file, is there any way to save all logs as when i connect it saves the logs without entering hour and minute

Best regards
Reply With Quote
  #8  
Old 04-27-2020, 01:58 PM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,322
Hi dahaboz,

I do not understand the remaining issue.

Of the code posted so far, enabling/disabling logging was even commented out, so I am not sure if you are relying on session configuration for logging or your script.

You have this line in your For loop:

Code:
           crt.Session.LogFileName = szSession
So I would expect each of your 16+ connected sessions to get the user provided session name as the log filename maybe.

Please clarify (with actual session names as examples) what log filenames you are getting vs what you want to be getting.
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #9  
Old 04-27-2020, 11:12 PM
dahaboz dahaboz is offline
Registered User
 
Join Date: Apr 2020
Posts: 7
Dear Brenda,

The actual session for example like (DPI_SPB_CC) connected to more than 16 nodes divided into three clusters.

The log filename I got is the IP address like(10.106.6.34) and what I want to get (10.106.6.34)--1408 as so watch time I connect to the server it saves the file and become a record to me.

Best regards
Attached Images
File Type: jpg spb dpi.JPG (83.7 KB, 41 views)
Reply With Quote
  #10  
Old 04-28-2020, 08:36 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,322
Hi dahaboz,

The last post has not helped clear up my confusion.

Are you logging in the sessions?

Or do you hope to configure logging via the script?
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #11  
Old 04-30-2020, 03:11 AM
dahaboz dahaboz is offline
Registered User
 
Join Date: Apr 2020
Posts: 7
Dear Bgagnon,

I already logging in the sessions as you can see in the attached, the issue for your hint for delete the (%h%m) make the // pop-up // save as screen disappear but it tasks me to another issue as the script saves only one log file even if I disconnect and try to connect again I found only one log file, not like earlier as I found many logs per connection,

hopefully, you got me.

Best regards
Attached Images
File Type: jpg spb securecrt.JPG (56.0 KB, 45 views)
Reply With Quote
  #12  
Old 04-30-2020, 11:21 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,322
Hi dahaboz,
Quote:
The log filename I got is the IP address like(10.106.6.34) and what I want to get (10.106.6.34)--1408 as so watch time I connect to the server it saves the file and become a record to me.
We already determined that you cannot use %h%m or all connections for a device (in any given day) will not append to the single log file. So I am not sure what functionality you are looking for at this point.

You can do %h:%m:%s -- (or some similar construct) logging on each line so that you have a record regarding the exact time of the activity.
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
  #13  
Old 05-01-2020, 12:49 AM
dahaboz dahaboz is offline
Registered User
 
Join Date: Apr 2020
Posts: 7
Dear Bgagnon,

unfortunately after trying your tow suggestions still // pop-up // save as screen appear, and it also ignores the first tab to be saved in the logs.

any way to modify the script to solve this issue.

Best regards
Reply With Quote
  #14  
Old 05-01-2020, 08:34 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,322
Hi dahaboz,

What changed? I thought that issue was resolved.

I need explicit steps to understand the issue.

This would be in the form of:
  • Run script
  • Sessions "name_here", "name_here", "name_here", etc. are opened
  • Configuration of logging in each session
  • Log files found in D:\SecurCRT Logs are named "log_filename_here", "log_filename_here", "log_filename_here", etc.
And perhaps even post some screenshots that show what files get written, prompting at what point, etc.

If your script has changed, I need you to post it again as well.

Better yet … post a video of the process! We just are not getting anywhere with words.
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730

Last edited by bgagnon; 05-01-2020 at 09:18 AM. Reason: addendum
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 07:36 AM.