Link to home
Create AccountLog in
Avatar of Bob Schneider
Bob SchneiderFlag 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!!
Avatar of ste5an
ste5an
Flag of Germany image

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.

User generated image
Avatar of Bob Schneider

ASKER

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?
Avatar of Arana (G.P.)
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.
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.
you can change the target directory without the need for the GUI directly into the registry:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions\Default%20Settings]
"LogFileName"="C:\\Users\\BShneider\\RaceLog\\putty.log"
"LogType"=dword:00000002

Open in new window

you can update the registry whenever you need to change the filename and just load the defaults
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
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.
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

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?
ASKER CERTIFIED SOLUTION
Avatar of Arana (G.P.)
Arana (G.P.)

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Incredibly helpful!  I can't thank you enough Arana!!!