A message from our CEO about the future of Stack Overflow and Stack Exchange. Read now.
11

typescript saves everything what is sent to your terminal which may include escape sequences for positioning, colors, brightness etc. (0x1B is the ESC character.) The terminal output contains CR and LF even if the usual line ending in text files is different. The character 0x1B makes dos2unix assume your input might be a binary file. Because modifying a ...


9

cat typescript | perl -pe 's/\e([^\[\]]|\[.*?[a-zA-Z]|\].*?\a)//g' | col -b > typescript-processed


9

0x1b should be part of a VT100 terminal color code or similar. http://www.termsys.demon.co.uk/vtansi.htm <ESC> represents the ASCII "escape" character, 0x1B. In general what script records is not what you see but what the terminal sees, so it's a raw terminal recording. It can even record timing information for scriptreplay to show what was going ...


7

Maybe with: if lsof -tac script "$(tty)" > /dev/null; then echo "I'm running under script" else echo "I'm not" fi You could add something like: lsof -tac script "$(tty)" > /dev/null && PS1="[script] $PS1" To your ~/.zshrc or ~/.bashrc, so the information on whether you're in script or not would be visible on your shell prompt. ...


7

I couldn't get tty2gif to work right with vim. So I hacked together ttygif.


7

You can playback your typescript capture and encode the corresponding screen region using something like: ffmpeg -y -f x11grab -s 100x100 -i :0.0+100,100 -pix_fmt rgb24 -r 5 Desktop/capture.gif -y overwrites the output (most useful when testing) -f x11grab forces the format to x11grab -s 100x100 captured video is 100x100 -i :0.0+100,100 top left corner ...


6

# The "sed -r" trick does not work on every Linux, I still dunno why: DECOLORIZE='eval sed "s,${END}\[[0-9;]*[m|K],,g"' => howto use: <commands that type colored output> | ${DECOLORIZE} tested on: - AIX 5.x / 6.1 / 7.1 - Linux Mandrake / Mandriva / SLES / Fedora - SunOS


5

Interesting problem. I found a small bash script could do the job pretty reliably: #!/bin/bash PP=$(ps -o ppid= $$) while [[ $PP != 1 ]] do LINE=$(ps -o ppid= -o comm= $PP | sed 's/^ *//') COMM=${LINE#* } PP=${LINE%% *} if [[ $COMM == script ]] # Might need a different comparison then echo "In script" exit 0 fi ...


5

Untested: record with ttyrec, and convert with tty2gif.


4

Have you tried having script be the outer part gnome-terminal -x script -c "ssh user@IP" logfile.log


3

Assuming that M- is meta and ^ is control, the sequence M-b M-^T M-^@ represents hex e4 94 80. The character ─ you gave is unicode U2500, "BOX DRAWINGS LIGHT HORIZONTAL". If you line up the bit patterns, you get something like 1110 0100 1001 0100 1000 0000 = e4 94 80 0 0100 1 0100 00 0000 = 2500 So this seems to be a multibyte encoding, where ...


3

The typescript output captures all the characters sent to the pty. If you use for example stty -opost to stop the terminal driver from doing its normal change of the newline character to CR+LF then you will see that you only have LF characters in the output. Hopefully helpful tip, use col -b < typescript to do a first pass at cleaning up the file.


3

There's an ansi2txt command in the colorized-logs package on Ubuntu. It removes ANSI color codes nicely, but it doesn't deal with things like progress bars produced by emitting ^H or ^M characters to overwrite text in place. col -b can deal with those, so for best results you can combine the two cat typescript | ansi2txt | col -b


3

most easy way to share typescript is http://shelr.tv/ It uses script or ttyrec as backend and you can puslish your typescript as easy as "shelr push last" :)


3

I solved the problem by running scriptreplay in a screen and the dumping the scrollback buffer to a file. The following expect script does this for you. It has been tested for logfiles with up to 250.000 lines. In the working directory you need your scriptlog, a file called "time" with 10.000.000 times the line "1 10" in it, and the script. I needs the ...


3

The manual page for script gives the answer: -t, --timing[=file] Output timing data to standard error, or to file when given. This data contains two fields, separated by a space. The first field indicates how much time elapsed since the previous output. The second field indicates how many characters were output this time. This information can ...


3

You can use the scriptreplay perl script provided by the scriptreplay_ng project in GitHub: https://github.com/scoopex/scriptreplay_ng : #!/usr/bin/env perl # # scriptreplay - play back typescript of terminal session # # # Author(s): # Joey Hess <joey@kitenet.net> # Marc Schoechlin <ms@256bit.org> # Hendrik Brueckner <hb-...


2

Perhaps you could encourage your admin to use good logging practices. Gnu Screen does this quite nicely. It adds quite a bit more functionality than you're looking for, and also has the ability to toggle logging, so he could turn it off himself, if he desired. It lacks the replay functionality, but it could be part of a solution, in that it tracks most input ...


2

There is probably only one thing missing from your example, the option -f to flush the write each time. script -f >(while read;do date;echo "$REPLY";done >>session.log)


2

Yes. While asciinema doesn't provide this natively, there are tools out there that can facilitate that for you. You can create your local recording like so: asciinema rec my_recording.json And then feed that into a tool like asciicast2gif: ./asciicast2gif my_recording.json my_recording.gif


2

No the problem is not with encoding. You don't seem to follow the prerequisites for screen as mentioned in the man page: Certain interactive commands, such as vi(1), create garbage in the type‐ script file. Script works best with commands that do not manipulate the screen, the results are meant to emulate a hardcopy terminal. You have all kind of stuff ...


2

Everything inside single quotes is not expanded, so just remove this parameter from the quotes: sudo script -a -c 'sudo picocom /dev/tty'"${2}"' | ts "%Y-%b-%d %H:%M:%S10"' /usr/local/logs/${1}.log Shell will take care of merging all parts together.


2

In case if you are running python script in Linux environment, follow the below steps before running the script: $ script console_log.txt $ run your python script $ exit (After the script completes execution) Entire console logs will be captured in "console_log.txt"


1

My own answer, after learning from the answer and the comment by icarus: You have to distinguish "a newline in a file" and "a newline in a console". In a console, the true newline is, counter-intuitively, CRLF, as we will see below. In UNIX convetion, in text files LF means a newline, and vice versa, you mean a newline by LF. (By "you mean", I mean say in a ...


1

Something like this in your .bash_profile or .bashrc might work for you: if test -t 0 -a -t 1 -a -z "$SCRIPTING" then export SCRIPTING="$HOME/.script.$(date +%Y%m%d_%H%M%S).$$)" exec script "$SCRIPTING" fi


1

It sounds like MacOS's Terminal has a feature where it extracts the current working directory from the process running in one tab (using /proc or similar) and uses it as the initial current working directory for a new tab. In this case, the process running in the first tab is script — which never bothers to change its current working directory, so new tabs ...


1

this might be a partial solution, depending on your needs: if you include \d \D{} in your PS1 string, each command prompt will include the date and time. that will give you the time at which the previous command finished. in the simplest case, do PS1='\d \D{} $ ' do that after invoking script (or in your .bashrc or whatever) and you will get a session....


1

As well as fixing up your PS1, you may be able to persuade applications not to emit these non-printing characters by exporting a suitable value in the TERM environment variable. The canonical one is probably export TERM=dumb at the beginning of your script session (or TERM=dumb script <args> when invoking). Assuming that you create your PS1 portably ...


1

A alternative for shelr.tv (which was a great option, and may end up being again) is showterm which you can self host, or use as is. Convert to video as you see fit, this is not a direct to video answer though.


Only top voted, non community-wiki answers of a minimum length are eligible