X-Recipient: archive-cygwin AT delorie DOT com X-Spam-Check-By: sourceware.org Message-ID: <47E6C055.221E3F4E@dessent.net> Date: Sun, 23 Mar 2008 13:40:53 -0700 From: Brian Dessent X-Mailer: Mozilla 4.79 [en] (Windows NT 5.0; U) MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Re: Logging all console activity to a text file References: <4FA6A488CF56458B8803BBFF00EB2C1F AT acer22fc5bc362> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Reply-To: cygwin AT cygwin DOT com Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Hussein Patwa wrote: > I'd like to log all console activity, both input and output to a text file > for later review. Uses for this could be, for example, demonstrating an > operation to someone unfamiliar with cygwin, or say, keeping a record of > console output for future reference. You should try the 'script' command from the util-linux package. It will capture all input and output from a terminal. Note that the file it produces really is an exact replica, containing all the terminal escape sequences as well as all keypresses (i.e. typos+backspaces included.) Because of that if you try to view it with 'less' or edit it with a text editor sometimes it will look like garbage. The only real reliable way of viewing it is to cat it to the terminal, or strip out the terminal escape sequences. There is also the 'replayscript' command but that is more oriented towards playing back the session with timing info. Another thing to be aware of when using 'script' is that it runs the commands attached to a pty (pseudoterminal), which is how it intercepts all I/O. This is normally not an issue, but it can be a problem if you're running non-Cygwin commands. The reason is that native apps don't understand ptys, they think their stdin and stdout are pipes and therefore sometimes interactive input doesn't work or output is buffered. If you are already using rxvt/xterm or have CYGWIN=tty then you're already using ptys so it will be no change. Some terminals also have a logging capability. For example xterm has the -l option. This only logs the output, altough that may not be an issue since every character you type is also echoed to stdout by the shell -- that's how you see what you've typed. I think putty has a similar option. > Can this be done either globally (logging start each time a cygwin session > starts), or individually (I can start and stop logging as I choose) and if > so how? If you wanted 'script' to log everything for every session by default, you could add it as the last command in the user's profile or the system profile -- or you could just change the command that starts the Cygwin session (normally cygwin.bat) to run script explicitly. You may have to use some logic to pick a unquely named filename each time, e.g. using the date command. If you want to start and stop logging, it works just like invoking a subshell, i.e. type "script filename", enter some commands, type exit, logging stops. Brian -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/