I have gnuwin32
and SFU. Neither has the script.exe
command.
Does anyone know if there is the script.exe
equivalent for Windows, other than from Cygwin, which I do not want to install (for reasons irrelevant for this discussion)?
I have gnuwin32
and SFU. Neither has the script.exe
command.
Does anyone know if there is the script.exe
equivalent for Windows, other than from Cygwin, which I do not want to install (for reasons irrelevant for this discussion)?
No, there is no Windows equivalent to the script
command; believe me, I have searched high and low.
In any case, you can use redirection to accomplish at least half of it. You will not see the output during execution, but you can see it afterwards in the file. Unfortunately it’s a compromise, but it can do when in a pinch.
The only thing that you need to look out for is that some programs write to more than one stream. In addition to standard out (stdout
), they may also write to standard error (stderr
) or standard log (stdlog
). So to make sure that you capture all output, you need to redirect both stdout
and stderr
(in Windows, stdlog
is automatically redirected to stdout
). In the example below, the Microsoft compiler (cl.exe
) prints the banner (header text) to stderr
, and the rest of the help text to stdout
.
C:\> cl /? > foobar.txt 2>&1
I am afraid copy-paste is the only way (redirecting output is not script command equivalent).
According to Microsoft Help Forum
Open the cmd prompt in a window format, i.e. not full screen...
Now right click on the head of the cmd promt, i.e. the blue strip on the top and there is a option of edit. There select the option mark, i.e. edit->mark,.You will get a cursor in the cmd promt, just select the area that you want to copy... then again go to the top right click edit-> copy
Now in a text file just paste and you will get the contents of the cmd prompt in the text file...
No non-cygwin that I know; but whatever your reasons are for not wanting cygwin, you may reconsider them knowing that you can separate its script.exe from cygwin and delete the unneeded parts of cygwin. Will be ugly but works and is portable, takes 5MB for me.
TL;DR create a bin
directory anywhere and with having manually installed the util-linux cygwin package, copy these files to that bin
then delete the rest of cygwin:
bin\cyggcc_s-1.dll
bin\cygiconv-2.dll
bin\cygintl-8.dll
bin\cygncursesw-10.dll
bin\cygreadline7.dll
bin\cygwin1.dll
bin\script.exe
bin\sh.exe
That's it. Here follows the intendedly very detailed description on how this can be found out, how to install cygwin and everything else.
The script
command (manual page) exists for windows as a non-default part of cygwin called script.exe
. You have to manually select its package for installation, currently it is in the package called util-linux. (note that while unadwised, technically it's possible to separate script.exe from an cygwin installation, if you provide its dependencies)
Once you have script.exe
, you can record a cmd session by starting script.exe -c cmd.exe
and typeing exit
at the end. You can set the output filename with eg. the -a
switch, the default name is typescript
and overwrite.
To find which exe (or other file) is in which package, you can search contents of packages of cygwin online: http://www.cygwin.com/packages/ E.g. look for "script.exe".
FYI, you can see the manual page for the script
command in a linux system by using the man command, typing man script
to the terminal (if you have man pages installed), or by online searching the keywords "man script typescript".
The pocket err.. backpack guide to cygwin:
Cygwin links every exe to its own .dll so requires copy of these dll(s) in addition to its exe files, but otherwise is useable as a collection of normal, windows-native exe files. However the standard way to use cygwin is to install it via its installer. The base package is reported to be about 30MB download and 90MB extracted, but you can select extra packages like util-linux for additional exes like script.exe
.
You can install packages via running the cygwin installer, currently called setup-x86.exe
for the x86 (previously it was called setup.exe
. Also it occasionally have updates. For example the old setup.exe is not working any more because the paths had changed on the servers; you need to download the new one). You go forward in a next-next-next manner in the installer until you see something that resembles a package list.
At top click option "keep" and view to "Full" if you ask me. Hover the mouse for information tooltips on what does these mean.
To get to the package list you usually do this on an x86: download and start setup_x86.exe
, click "Next" for the welcome screen, select "Install from internet" and click Next, choose your install directory and click Next, choose a temporary package cache directory and click Next, choose "Direct connection" (or whatever you need) and click Next, if it can download the mirror list, it is actually in alphabetical order for English name of countries (hard to belive but true), you can see it from the domain name endings (.com/.net/.org first, then eg. .au, .de, .gr, etc.). Select a mirror that you think is close to you and click Next, if it succeeds to download you can see the package list.
Cygwin may be installed via its installer but the directory it creates is actually portable. I used to zip it with 7z and extract and use it on other computers with success.
The default install is claimed to be 90MB extracted and 30MB to download. You can an example of the default packages on this nabble thread to have an idea what to install to a minimal system. You can actually unselect these packages and only select eg. util-linux when installing, and the cygwin installer will ask you if you want to install the dependencies (requirements) of util-linux, too. I'm not sure if unselecting the default packages will still install the mintty.exe
terminal or bash
, though, which are handy and usually expected by the cygwin environment although they are not actually necessary for using any of the cygwin exes.
NOTE that it is unadwised that you separate any part of the cygwin installation, not because it cannot work but because if you have more than one exes rely on the cygwin.dll, any time the cygwin.dll gets updated and you happen to make a copy of the new dll for another one of the exes, the dll load may try to load the wrong dll for example if it's in the PATH in a prior position compared to the other.
That said, to separate script.exe (and potentially delete rest of cygwin) - you can do it, you copy it's dll dependencies but it's not enough. It tries to load a sh.exe even if there are no unixy shells around, so it also needs sh.exe, but it still won't find it unless you put them in a directory called "bin" (that could be anywhere, by the way). So to have a functional script.exe separated from cygwin, you need these files in this structure (as of this writing):
bin\cyggcc_s-1.dll
,
bin\cygiconv-2.dll
,
bin\cygintl-8.dll
,
bin\cygncursesw-10.dll
,
bin\cygreadline7.dll
,
bin\cygwin1.dll
,
bin\script.exe
,
bin\sh.exe
,
The bin
directory can be anywhere, by the way
You can get the dll dependency for example with the Total Commander lister plugin fileinfo
There are workarounds to do what you want.
The cygwin utility package (google cygwin to find it) actually has a script command. If you install that package, modify your PATH variable appropriately, and type script -c cmd it will start a dos shell and capture the input and output in a file named typescript. The script command has several options. (I leave it as a exercise for the reader to find the documentation :)
Cygwin will install lots of stuff on your computer. If you want to keep it simple you can install the tee command as mentioned above and type cmd | tee filename-of-your-choice. This will capture the input and output in filename-of-your-choice.
Here is an log of the second solution. Notice that the logged input and output is in a subshell. (I would have posted a screenshot but this site won't let me - I haven't talked enough).
Microsoft Windows [Version 6.1.7601] Copyright (c) 2009 Microsoft
Corporation. All rights reserved.
C:\Users\David>echo topshell topshell
C:\Users\David>doskey /h echo topshell doskey /h
C:\Users\David>cmd | tee log.txt Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\David>echo subshell subshell
C:\Users\David>doskey /h echo subshell doskey /h
C:\Users\David>exit
C:\Users\David>doskey /h echo topshell doskey /h cmd | tee log.txt
doskey /h
C:\Users\David>type log.txt Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\David>subshell
C:\Users\David>echo subshell doskey /h
C:\Users\David> C:\Users\David>
I just tried both solutions. The second (cmd | tee ...) is better as it allows command recall with the arrow keys. The first solution (script.exe) does not.
script.exe
is in the util-linux package. script
documentation: linux.die.net/man/1/script
man
being the linux command for manual page (if you have the manuals installed on your computer system). Also note that man
is only three letters if you know it but a totally unknown area of think-target in an unknown direction if you don't. It requires less typing than 'leaving as excercise' ;)
It sounds like you want the tee
command. You can get it here. Tee lets you read from standard input and write to standard output and files.
script
command is that xe is looking for a Windows equivalent for is. It's the Linux command by that very name, whose manual page is a mereman script
away.script
command.