Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

PuTTY - starting from command line with logging enabled

2,559 views
Skip to first unread message

Nomad

unread,
Aug 20, 2008, 10:56:47 AM8/20/08
to
I am in a 100+ unix server environment, and due to some security
requirements, instead of using my master administration server as a
jumpboard, now I have to launch separate sessions to each of these
servers when I need to login. I am quite sufficient in unix
environment and do whatever I wish to do but when it comes to windows,
writing batch files is harder than pulling teeth.

Now, my requirement is, when I launch an ssh session, I want it to
start with logging enabled, but I do not want to go and manually
create 100+ sessions (number expanding weekly, if not daily) and mark
each session with logging enabled. This is not something feasible for
me. I read thru the PuTTY manual but did not see any command line
switch to accomplish this. I need to save my last, say 50, sessions
screen input and output to any server I go into, on my local machine.
I was hoping to write a batch file which will accept the server name
as a command line argument and create a new log file with datestamp
being part of the filename as well as the server name.

I thought of using AutoHotKey to send a series of keystrokes to the
terminal window to open up the context menu (drop down from upper left
corner) but could not figure out if there is a way to drop it down
with a key stroke. I tried, many combinations of win-alt-ctrl-shift
with any alphabetical and numerical keys but was not able to drop down
the context menu.

If anyone was able to accomplish this before, I really would like to
hear how you did it.

Thanks in advance.

Dale Dellutri

unread,
Aug 20, 2008, 11:25:08 AM8/20/08
to

You don't use command line switches. You set up a named session,
for example, toUnixServer, then set all the options you want for
that session including logging (see Session, Logging), then load
it at PuTTY startup:
putty -load "toUnixServer"

The log file can be customized to include hostname, date and time.

See the documentation (especially section 4.2):
http://www.chiark.greenend.org.uk/~sgtatham/putty/docs.html

--
Dale Dellutri <ddelQ...@panQQQix.com> (lose the Q's)

Nomad

unread,
Aug 20, 2008, 1:30:13 PM8/20/08
to
On Aug 20, 8:25 am, Dale Dellutri <ddelQQQl...@panQQQix.com> wrote:

> You don't use command line switches.  You set up a named session,
> for example, toUnixServer, then set all the options you want for
> that session including logging (see Session, Logging), then load
> it at PuTTY startup:
>   putty -load "toUnixServer"
>
> The log file can be customized to include hostname, date and time.

This is the very thing that I am trying to avoid. Today I have 100+
servers tomorrow it will be 120 next year it will be god knows how
many. Trying to keep track of them by this manually creating session
files, is not something I want to do continuously. This is the thing
that I am trying to circumvent if you read my original message.
Otherwise I know the existence of this option. It just is not feasible
for me to employ.

Darren Dunham

unread,
Aug 20, 2008, 8:17:00 PM8/20/08
to
Nomad <melbu...@gmail.com> wrote:
> On Aug 20, 8:25?am, Dale Dellutri <ddelQQQl...@panQQQix.com> wrote:
>
>> You don't use command line switches. ?You set up a named session,

>> for example, toUnixServer, then set all the options you want for
>> that session including logging (see Session, Logging), then load
>> it at PuTTY startup:
>> ? putty -load "toUnixServer"

>>
>> The log file can be customized to include hostname, date and time.
>
> This is the very thing that I am trying to avoid.

I don't follow. Don't you want a command line option?

How is 'putty -load "toUnixServer"' significantly different for you from
a hypothetical (but unavailable) option like --logging?

--
Darren

Dale Dellutri

unread,
Aug 21, 2008, 7:18:20 AM8/21/08
to
On Wed, 20 Aug 2008 10:30:13 -0700 (PDT), Nomad <melbu...@gmail.com> wrote:
> On Aug 20, 8:25?am, Dale Dellutri <ddelQQQl...@panQQQix.com> wrote:

> > You don't use command line switches. ?You set up a named session,


> > for example, toUnixServer, then set all the options you want for
> > that session including logging (see Session, Logging), then load
> > it at PuTTY startup:

> > ? putty -load "toUnixServer"


> >
> > The log file can be customized to include hostname, date and time.

> This is the very thing that I am trying to avoid. Today I have 100+
> servers tomorrow it will be 120 next year it will be god knows how
> many. Trying to keep track of them by this manually creating session
> files, is not something I want to do continuously. This is the thing
> that I am trying to circumvent if you read my original message.
> Otherwise I know the existence of this option. It just is not feasible
> for me to employ.

Then do it this way:

1. Modify the Default session to include logging with a
file name like unixserver-&H-&Y&M&D&T.log in whatever
directory you choose. The H will be filled in with
the hostname, YMDT with the year, month date time.
Save the Default session

2. In your batch file, start putty like:
putty.exe -ssh %user%@%host%
(I think that's the right DOS syntax)
where %user% and %host% will be filled in as you
described.

This will use the Default session which you already
modified to include logging.

All of this is described in the documentation at:

Nomad

unread,
Aug 21, 2008, 9:22:36 AM8/21/08
to
On Aug 21, 4:18 am, Dale Dellutri <ddelQQQl...@panQQQix.com> wrote:

> Then do it this way:
>
> 1. Modify the Default session to include logging with a
>  file name like unixserver-&H-&Y&M&D&T.log in whatever
>  directory you choose.  The H will be filled in with
>  the hostname, YMDT with the year, month date time.
>  Save the Default session
>
> 2. In your batch file, start putty like:
>    putty.exe -ssh %user%@%host%
>  (I think that's the right DOS syntax)
>  where %user% and %host% will be filled in as you
>  described.
>
> This will use the Default session which you already
> modified to include logging.
>
> All of this is described in the documentation at:
>  http://www.chiark.greenend.org.uk/~sgtatham/putty/docs.html
>
> --

> Dale Dellutri <ddelQQQl...@panQQQix.com> (lose the Q's)


I tried doing this. I inserted a fixed log name, nothing fancy with %
signs and such, enabled logging everything (not just printable
characters) just to test and saved the default but when I start a
session, it still starts without the logging enabled.

Nomad

unread,
Aug 21, 2008, 9:24:56 AM8/21/08
to
On Aug 20, 5:17 pm, ddun...@taos.com (Darren Dunham) wrote:

How it is different is, when you use -load <profile> option, you are
assuming that the profile already exists and saved. I am trying to
avoid creating 100+ profiles, one-by-one as well as having to remember
to create a new profile everytime a new server gets added to the
landscape.

Dale Dellutri

unread,
Aug 21, 2008, 10:34:38 AM8/21/08
to
On Thu, 21 Aug 2008 06:22:36 -0700 (PDT), Nomad <melbu...@gmail.com> wrote:
> On Aug 21, 4:18?am, Dale Dellutri <ddelQQQl...@panQQQix.com> wrote:

> > Then do it this way:
> >
> > 1. Modify the Default session to include logging with a

> > ?file name like unixserver-&H-&Y&M&D&T.log in whatever
> > ?directory you choose. ?The H will be filled in with
> > ?the hostname, YMDT with the year, month date time.
> > ?Save the Default session


> >
> > 2. In your batch file, start putty like:

> > ? ?putty.exe -ssh %user%@%host%
> > ?(I think that's the right DOS syntax)
> > ?where %user% and %host% will be filled in as you
> > ?described.


> >
> > This will use the Default session which you already
> > modified to include logging.
> >
> > All of this is described in the documentation at:

> > ?http://www.chiark.greenend.org.uk/~sgtatham/putty/docs.html

> I tried doing this. I inserted a fixed log name, nothing fancy with %
> signs and such, enabled logging everything (not just printable
> characters) just to test and saved the default but when I start a
> session, it still starts without the logging enabled.

I just tried this and it worked.

When you set up the "fixed log name", did you first browse to
a folder in which you have write permission? (The default
is probably not writable by you.)

Are you sure you saved the Default? If you bring up PuTTY via
the GUI, are your settings showing in the Session Logging config
panel?

Also, the "fancy" log names use "&" before variable names,
not "%".

Darren Dunham

unread,
Aug 21, 2008, 1:42:07 PM8/21/08
to
Nomad <melbu...@gmail.com> wrote:

> On Aug 20, 5:17?pm, ddun...@taos.com (Darren Dunham) wrote:
>
>> How is 'putty -load "toUnixServer"' significantly different for you from
>> a hypothetical (but unavailable) option like --logging?
>
> How it is different is, when you use -load <profile> option, you are
> assuming that the profile already exists and saved. I am trying to
> avoid creating 100+ profiles, one-by-one as well as having to remember
> to create a new profile everytime a new server gets added to the
> landscape.

Why would you need 100+ profiles for this? Just use whatever you use
today, enable logging, save a profile for it, then use that profile as
the argument to -load. That's only one profile....

--
Darren

Darren Dunham

unread,
Aug 21, 2008, 1:44:13 PM8/21/08
to
Nomad <melbu...@gmail.com> wrote:
> How it is different is, when you use -load <profile> option, you are
> assuming that the profile already exists and saved. I am trying to
> avoid creating 100+ profiles, one-by-one as well as having to remember
> to create a new profile everytime a new server gets added to the
> landscape.

Ahh, I see. It's not so much *enabling* the logging as getting the
filename set usefully based on the host you're connecting to. That was
the bit I misunderstood.

--
Darren

0 new messages