Avatar of Bob Schneider
Bob Schneider
Flag for United States of America asked on

Logging Putty Output using vb6

I need to log a putty session using vb6.  I am able to initiate Putty using the following:

Shell "C:\Program Files\PuTTY\putty.exe telnet:192.168.1." & sWhichBox & ":10001", vbNormalFocus

Now I need to direct the output to a specific file in a specific directory using vb6.  The location  will look like this: sPath & "trident_" & sWhichBox & ".log"

I would really appreciate any assistance I can get with this?

Thank you very much!!
SSH / Telnet SoftwareVisual Basic Classic

Avatar of undefined
Last Comment
Bob Schneider

8/22/2022 - Mon

Can you describe your use-case and give use more context?

For batch usage you would use plink and redirect the stdin/stdout/stderr. For doing this with putty, you need to set the logging in the putty UI first and store that settings. Then the output is copied to file.

Bob Schneider

I have a race timing box that reads data from race finishers and I need to use putty to bring that data into my pc.  I want to do that via my vb6 code.  I can initiate putty and get the data to stream into putty but I also need it to write the output to a text file.  I want to do all of this without physically accessing the putty GUI.  Again, everything works except sending it to a text file...ie: logging the output.  Is there a parameter that I can include in my call to putty via shell that will allow me to do that?
Arana (G.P.)

you need to first configure putty using the GUI to setup the path and name of logfile,

Since you are using VB6 why not just read the data from the timing box without putty?
you can use a MsComm control to open a serial port, get the data into the MsComm buffer and write it to a file , everything without the need for puttty or any other external program.
Your help has saved me hundreds of hours of internet surfing.
Bob Schneider

I can't do your first suggestion because the target directory changes from race to race and depending on which timing box we are using.

I would LOVE a sample of how to implement your second suggestion!!!!  Note that I connect to the timing box via ethernet.

Let me just say that if this is beyond the scope of the help I can expect from my subscription to this service I would gladly pay a fair amount for someone to assist with this.
Arana (G.P.)

you can change the target directory without the need for the GUI directly into the registry:
Windows Registry Editor Version 5.00

Open in new window

you can update the registry whenever you need to change the filename and just load the defaults
Arana (G.P.)

regarding the second suggestion, are you using TELNET then?, I assumed you were using Serial communication (from your other post).

let me know if the code you mention in your other post already does this connection, you may already have everything you need and only require a few tweaks
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Bob Schneider

I am using TelNet, yes.  I am connecting to the timing box and getting the data stream.  I just don't know how to send it to a text file that is determined dynamically.
Arana (G.P.)

you update the registry using the .reg file (the registry code in my last comment), you save that code to a REG file , execute it with :  
regedit /s file.reg  

then you just do what you are already doing, so everytime you need to change the path you need to close putty, update the registry and open putty again.
or without the registry updates using putty command line switches just:
Shell "C:\Program Files\PuTTY\putty.exe telnet:192.168.1." & sWhichBox  & ":10001" &" -sessionlog " & sPath & "trident_" & sWhichBox  & ".log"  , vbNormalFocus

Open in new window

Bob Schneider

Awesome.  Thanks!  We are almost there...and I can't express how much I appreciate this.  Last thing: sPath could have spaces in it.  Is there a way to escape that?
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
Arana (G.P.)

View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Bob Schneider

Incredibly helpful!  I can't thank you enough Arana!!!