Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

is there a command which configures the PuTTY to open up with "Session Logging" in "Printable output". I could do this manually, but i want to put this in a cammand line which will configure the PuTTY and open the console with these configurations.

The configurations what i want are --> In Sessions category : Session logging should be printable output. By default it is None and give the path of the logfile name. And select "always append to the end of it"

--> Select "Line discipline options"

Just like, the below command

putty.exe -serial com4 -sercfg 115200 this configures the PuTTY with serial line COM port 4 and Speed 115200.

i want similar command line for the said configurations. One thing is, the session can be saved with the required settings and loaded, but the script won't be universal. That is, it cannot be run on all the PCs.i will have to create many sessions (since i am using multiple baud rates/speed) on each and every PC where my script will be executed.

And what command should be used to close the PuTTY console? i tried typing "exit" but in vain! i had to use mouse. But since i am automating, i don't want any intervention. i will be using it in a .bat file and a .vbs to send the commands to the PuTTY console. (On a Windows PC)

Any help would be sincerely appreciated. Thanks in advance!

share|improve this question

migrated from stackoverflow.com Apr 5 '13 at 21:25

This question came from our site for professional and enthusiast programmers.

    
I'm not familiar with putty but the docs mention a -load command line parameter that will load a saved session. If "Session Logging" and "Printable Output" are saved with a session, that may do what you want. –  Nate Hekman Apr 5 '13 at 13:40
    
If you're sending commands from a vbs, why can't you just accomplish the task using a VB program? –  Kruug Apr 5 '13 at 21:31
add comment

1 Answer

Unless there's an undocumented option, PuTTY doesn't have command-line switches for controlling logging (check the documentation, section 3.8). However, you could write a wrapper script that changes the default settings in the registry before launching PuTTY, e.g.:

@echo off

setlocal

set settings=HKCU\Software\SimonTatham\PuTTY\Sessions\Default%%20Settings

reg add "%settings%" /v LogFileName /t REG_SZ /d "%~1"
reg add "%settings%" /v LogType /t REG_DWORD /d 0x1
reg add "%settings%" /v LogFileClash /t REG_DWORD /d 0x0

putty ...

endlocal

Save it as e.g. putty.cmd and start it like this:

putty.cmd "C:\path\to\putty.log"
share|improve this answer
    
Thanks, but how to close the opened PuTTY session? any command for closing it or running it in background so that it is not shown? –  bayman Apr 8 '13 at 11:03
    
Which command could be used to exit from a session (if any) depends on the service/shell you're connected to. And if you don't want an interactive shell in the first place, I'd suggest using plink instead. –  Ansgar Wiechers Apr 8 '13 at 14:19
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.