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-18-2017, 12:24 PM
hooknife hooknife is offline
Registered User
 
Join Date: Mar 2007
Posts: 34
Log commands issued to remote system?

I know that it's possible to log commands to your clipboard via the script listed below but is it possible to have SecureCRT create and write a local file with the commands I issue on a remote system?

https://forums.vandyke.com/showpost....86&postcount=1

Thank you!
Reply With Quote
  #2  
Old 05-18-2017, 12:48 PM
jdev's Avatar
jdev jdev is offline
VanDyke Technical Support
 
Join Date: Nov 2003
Location: Albuquerque, NM
Posts: 1,001
Quote:
Originally Posted by hooknife View Post
is it possible to have SecureCRT create and write a local file with the commands I issue on a remote system?
Do you mean write the results of the commands you issue to a file on your local system?

If so, then yes! You don't even need scripting to accomplish this. Just enable logging in either your session options (so that it starts automatically every time you connect with the session), or you can choose File > Log Session to start logging in an ad hoc manner until you either get disconnected or choose File > Log Session again.

If you desire to write the results to a file in a different way, similar to how this script you referenced works, what would be the name of the file? Would it always be the same no matter the host/session you're connected with, or would the name of the file change based on the host/session? There's a lot of variables involved there that aren't present when working with the clipboard.

If you want an example of running commands and logging their results to a file (or files), see the Run Commands On Multiple Hosts and Log Results or the Save Screen Text to a File examples in the Script Examples "sticky". There's also information about reading/writing from/to files in the scripting guide if you're on Windows and using VBScript.

If you're looking to do something else, would you be so kind as to please provide clarification?

--Jake
__________________
Jake Devenport
VanDyke Software
Technical Support
YouTube Channel: https://www.youtube.com/vandykesoftware
Email: support@vandyke.com
Web: https://www.vandyke.com/support
Reply With Quote
  #3  
Old 05-18-2017, 03:43 PM
hooknife hooknife is offline
Registered User
 
Join Date: Mar 2007
Posts: 34
Thank you for the long response.

I'm actually looking to have an audit trail of the commands I enter into routers and switches written back to a local file on my PC. I'm wanting to be able to look back though the commands I've issued but without the corresponding output from the router or switch that would come from the command.
Reply With Quote
  #4  
Old 05-18-2017, 06:14 PM
jdev's Avatar
jdev jdev is offline
VanDyke Technical Support
 
Join Date: Nov 2003
Location: Albuquerque, NM
Posts: 1,001
Quote:
Originally Posted by hooknife View Post
I'm actually looking to have an audit trail of the commands I enter into routers and switches written back to a local file on my PC. I'm wanting to be able to look back though the commands I've issued but without the corresponding output from the router or switch that would come from the command.
I've added a feature request for SecureCRT to log outgoing data, but not incoming data. A "gotcha" comes to mind: How would SecureCRT distinguish between a command sent, vs. sensitive data like passwords that should not be written to a plain text file? That would not be easy to accomplish in a reliable way that would work across all possible types of devices SecureCRT could connect to.

Perhaps what would work is to have a way to parse your existing log files with an analyzer that looks for commands sent, and simply displays them for you. Existing log files only include data received from a remote system (so commands you sent have to be echo'd back to SecureCRT, and the remote would hopefully not echo back sensitive passwords that you type in, avoiding related security concerns with the approach of logging all outgoing data).

OK. That's got me thinking...

If a scripting solution ever materializes from my thoughts, I'll post it here.

--Jake
__________________
Jake Devenport
VanDyke Software
Technical Support
YouTube Channel: https://www.youtube.com/vandykesoftware
Email: support@vandyke.com
Web: https://www.vandyke.com/support
Reply With Quote
  #5  
Old 05-19-2017, 04:59 AM
hooknife hooknife is offline
Registered User
 
Join Date: Mar 2007
Posts: 34
This script appears to capture the data I'm looking for but it copies it to your clipboard instead of writing it to a file. Is there a way of adjusting the script so that it creates a individual file for each session instead of copying the commands to the clipboard?

https://forums.vandyke.com/showpost....86&postcount=1

Quote:
Originally Posted by jdev View Post

Perhaps what would work is to have a way to parse your existing log files with an analyzer that looks for commands sent, and simply displays them for you. Existing log files only include data received from a remote system (so commands you sent have to be echo'd back to SecureCRT, and the remote would hopefully not echo back sensitive passwords that you type in, avoiding related security concerns with the approach of logging all outgoing data
The above script does exactly what I want minus writing the data to a file.

Again, thanks for the help!

Last edited by hooknife; 05-19-2017 at 05:04 AM. Reason: Added more details
Reply With Quote
  #6  
Old 05-19-2017, 12:12 PM
jdev's Avatar
jdev jdev is offline
VanDyke Technical Support
 
Join Date: Nov 2003
Location: Albuquerque, NM
Posts: 1,001
Earlier, you said (my emphasis added):
Quote:
I'm wanting to be able to look back though the commands I've issued but without the corresponding output from the router or switch that would come from the command.
I'm stumped. The script example you referenced isn't designed to behave in the way you described.

But...
If the script currently behaves in the way you desire, here's a simple way to modify it to write to a file instead of the clipboard:
  1. Find the line of code in the script that stores the data in the clipboard. It looks like this: crt.Clipboard.Text = strCmdResults

  2. Replace that line with the following block of code:
    Code:
        Set fso = CreateObject("Scripting.FileSystemObject")
        Set objFile = fso.OpenTextFile("C:\MyCommandsFile.txt", 8, True)
        objFile.Write(strCmdResults)
        objFile.Close
    You would want to replace the "C:\MyCommandsFile.txt" with the actual path to the file you desire to write to.

--Jake
__________________
Jake Devenport
VanDyke Software
Technical Support
YouTube Channel: https://www.youtube.com/vandykesoftware
Email: support@vandyke.com
Web: https://www.vandyke.com/support
Reply With Quote
  #7  
Old 05-23-2017, 01:14 PM
hooknife hooknife is offline
Registered User
 
Join Date: Mar 2007
Posts: 34
I made a mistake thinking the script I referenced did what I was hoping - very sorry.

Back to the drawing board...
Reply With Quote
  #8  
Old 10-02-2018, 07:53 AM
akb akb is offline
Registered User
 
Join Date: Oct 2018
Posts: 1
Hi.

Was this implemented? I mean logging of just the commands sent and not the output.
Reply With Quote
  #9  
Old 10-02-2018, 08:31 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,350
Hi akb,

No, hooknife's was the first and only request until now.

Should a future release of SecureCRT include this feature, notification will be posted here.

If you prefer direct email notification, send an email to support@vandyke.com and include "Feature Request - Forum Thread #12705" in the subject line or use this form from the support page of our website.
__________________
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 09:03 AM.