suzdraws / mintty

Automatically exported from code.google.com/p/mintty
0 stars 0 forks source link

Add new command line argument to save the MinTTY output to a log file #75

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
In PuTTY it is possible to select a "log file" to which the terminal output
is automatically saved. We use this quite often to monitor the output of
the terminals that we run through putty.

Would it be possible to add a similar feature to MinTTY? Ideally you should
be able to pass a new type of parameter when you run MinTTY (for example
--log) where you could specify the file where the terminal output would be
saved.

Note that in PuTTY the output is saved as it is being written (i.e. it is
not written when you close PuTTY)

Also, it would be great if you could do the opposite, which is to tell
MinTTY to read commands from a file. Ideally MinTTY should not just execute
all the commands on the file and then exit, but instead it should wait
until a new line is written to the file and then it would execute it. 

With these 2 features, you could easily control the program that is being
run by MinTTY, since you would be able to send commands to it through the
command file and read the output through the log file.

Cheers!

Aem

Original issue reported on code.google.com by aemc...@yahoo.com on 27 Mar 2009 at 11:36

GoogleCodeExporter commented 9 years ago
I'd be very surprised if existing Unix/Cygwin facilities such as I/O 
redirection,
tee, screen, and just passing an input file to the shell couldn't already do 
what you
need. As far as I can tell, rxvt or xterm don't support log files either.

(Having the log file support in PuTTY makes sense because it's a standalone 
solution.)

Original comment by andy.koppe on 27 Mar 2009 at 9:55

GoogleCodeExporter commented 9 years ago
Actually, xterm does support logging if it's been compiled in, so --log shall 
go in
after all.

Original comment by andy.koppe on 28 Mar 2009 at 7:37

GoogleCodeExporter commented 9 years ago

Original comment by andy.koppe on 28 Mar 2009 at 7:38

GoogleCodeExporter commented 9 years ago
Implemented --log option in r221 on trunk.

Original comment by andy.koppe on 28 Mar 2009 at 11:12

GoogleCodeExporter commented 9 years ago

Original comment by andy.koppe on 7 Jun 2009 at 8:02

GoogleCodeExporter commented 9 years ago
Thanks a lot. This will be really useful! :-)

P.S.- Sorry for the long delay on answering. I was on a looong vacation :-)

Original comment by aemc...@yahoo.com on 17 Aug 2009 at 10:52

GoogleCodeExporter commented 9 years ago
You're welcome. Btw, I recently stumbled across the 'script' utility in Cygwin's
'util-linux' package, which provides an easy way to log the output of any 
command.
Unlike minTTY's logging facility, it has the ability to append to an existing 
log
file. And it puts timestamps at the start of end of the log, which might come 
in handy.

With minTTY, it can be used like this:

  mintty script -c 'bash -l' logfile

Original comment by andy.koppe on 5 Sep 2009 at 2:41

GoogleCodeExporter commented 9 years ago
Issue 9 has been merged into this issue.

Original comment by andy.koppe on 5 Sep 2009 at 2:44

GoogleCodeExporter commented 9 years ago
Notes:
======

1) Replace "username" in LOGDIR below with actual username or change to whatever
location you prefer. Please make sure the directories for LOGDIR and TIMDIR 
already
exist.

2) playsession script can be past a session Logfile name (without the extension)
and a Speed up Factor (Divisor) after the Logfile name.

3) If you are using .bash_profile to change/modify any enviornment varialbles
please do so before calling .bashrc otherwise they will not be available in
the nested Shell which gets logged.

4) You will have to logout twice (i.e. exit twice) to close the Cygwin Terminal.

###############################################################################

#Create a ".logrc" file in your home directory with the following lines in it

# File to store location of Session Logs and Timing Files

LOGDIR="/cygdrive/c/Users/username/Documents/Cygwin Terminal Logs/"
TIMDIR="$LOGDIR""Timing Files/"
LOGFILE="Session-$(date +%Y%m%d-%H%M%S-%N)"

###############################################################################

#Create a "bin/logsession" file in your home directory with the following lines
#in it and make the file executable.

#!/bin/bash
#File to initiate the session logging to a log file

if [ -f "${HOME}/.logrc" ] ; then
 source "${HOME}/.logrc"
#
# Check if user initiated request for session logging and start the logging file
#
  if [ $0 == "${HOME}/bin/logsession" ] ; then
   /usr/bin/script --timing="$TIMDIR""$LOGFILE.tm" "$LOGDIR""$LOGFILE.log"
#
# Session logging not initiated by user (i.e. initiated by .bashrc)
# Check if this is topmost SHELL (to avoid recursive loop) and start logging 
file
#
  elif [ $SHLVL == 1 ] ; then
   /usr/bin/script --timing="$TIMDIR""$LOGFILE.tm" "$LOGDIR""$LOGFILE.log"
  fi
fi

###############################################################################

#Create a "bin/playsession" file in your home directory with the following lines
#in it and make the file executable.

#!/bin/bash

if [ -f "${HOME}/.logrc" ] ; then
 source "${HOME}/.logrc"
#
# Check if user passed a speedup factor
#
  if [[ $2 ]] ; then
   echo
   echo "********** Starting playsession for $1 at $2X Speed **********"
   echo
   /usr/bin/scriptreplay --timing="$TIMDIR""$1.tm" "$LOGDIR""$1.log" "$2"
   echo
   echo "********** Finished playsession for $1 at $2X Speed **********"
   echo
#
# No speedup factor
#
  else
   echo
   echo "********** Starting playsession for $1 **********"
   echo
   /usr/bin/scriptreplay --timing="$TIMDIR""$1.tm" "$LOGDIR""$1.log"
   echo
   echo "********** Finished playsession for $1 **********"
   echo
  fi
fi

###############################################################################

#Add the following lines at the end of your ".bashrc" file in your home 
directory.

# Log all the session output to a log file

if [ -f "${HOME}/bin/logsession" ] ; then
  source "${HOME}/bin/logsession"
fi

Original comment by anuragko...@gmail.com on 11 Feb 2013 at 11:41

Attachments: