1

I'm trying you use the script command simply to save some prompts and output.

On unix, the output looks correct.

Script started on Sun 11 Sep 2016 06:34:13 PM EDT
[name@serv ~]$ mkdir myrepos
[name@serv ~]$ cd myrepos
[name@serv myrepos]$ svnadmin create testrepo
[name@serv myrepos]$ cd ../project

however, when I FTP the file to windows, I get:

Script started on Sun 11 Sep 2016 06:34:13 PM EDT
]0;name@serv:~[?h[name@serv ~]$ svn[K[K[Kmkdir myre[K[Krepos
]0;name@serv:~[name@serv ~]$ cd myrepos
]0;name@serv:~/myrepos[name@serv myrepos]$ svnadmin create testrepo[K[K[K[

Notepad shows the above with Ks and special character missing rectangles. Notepad++ shows me not only the Ks, but random ESC, BEL, and BS blocks.

I was hoping it was as simple as:

unix2dos original.txt windows.txt

but this tells me unix2dos: problems converting file windows.txt

Running iconv -f UTF-8 -t ISO-8859-1 in.txt > out.txt found here didn't help me either. At this point, I'm lost.

Thank you for any help.

Community
  • 1
  • 1
CeePlusPlus
  • 803
  • 1
  • 7
  • 26
  • 1
    The problem is that `script` records everything that's written to the terminal. If you type while entering a command, you'll see the final line, but the file will record the control sequences used to move the cursor back and forth. It will also record any control sequences used for highlighting in your shell prompt. You can see this on the Unix side with `cat -A` or `cat -v`. – Keith Thompson Sep 14 '16 at 00:06
  • Suggestion: Temporarily set your prompt to something simple, and be careful when typing any commands you want to record. Or copy-and-paste the output from your terminal rather than using `script`, so you only get what appears on the screen. – Keith Thompson Sep 14 '16 at 00:06

1 Answers1

2

It's not that simple, but you can transform the file on the Unix side, e.g., using sed. unix2dos and iconv solve a different problem than this, and cannot help with it.

There are several related answers, but I prefer the script which I wrote to answer Can I programmatically “burn in” ANSI control codes to a file using unix utils?.

The script is described briefly on one of my webpages, with some examples. It can be downloaded from that page, in a gzip'd tarfile.

Starting with the tarball...

tar xf misc-scripts.tar.gz
mv misc-scripts-2*/script2log .
rm -rf misc-scripts-2*

(unless you are interested in the other scripts: the tarball is simply a snapshot with files up to a given date which expands to a directory named with that date).

To use it, put script2log in your path, or just run it:

./script2log typescript >plaintext.log

or

./script2log -o plaintext.log typescript
Community
  • 1
  • 1
Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105
  • both answers are great and a good place to start digging into the root cause . – z atef Sep 12 '16 at 00:49
  • So i'm still learning as to what exactly is going on, but I'm definitely getting the idea. Wanting to use your fancy script though, (as sed didn't work completely), can I get a eli5 on how to use script2log ? Thanks. – CeePlusPlus Sep 13 '16 at 04:41
  • While definitely far cleaner then I was using, I have scenario where the script deleted more then it should. Would you be interested in the files to help improve the script? – CeePlusPlus Sep 20 '16 at 03:02
  • sure - I can take a look :-) – Thomas Dickey Sep 20 '16 at 12:27