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)?

link|improve this question

45% accept rate
2  
And what is script.exe? Please provide a link. – Nifle Aug 20 '11 at 8:22
Do you mean something like Bash that allows shell scripts? – Isxek Aug 20 '11 at 12:33
1  
Oh come on! The questioner has stated quite explicitly in the question title what the 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 mere man script away. – JdeBP Aug 20 '11 at 23:19
possible duplicate of Dos and/or Windows versions of Unix SCRIPT command – Synetech Aug 23 '11 at 2:19
I would have agreed with you had the original post been focused exclusively on the script command. – mark Aug 23 '11 at 9:01
show 1 more comment
feedback

4 Answers

up vote 2 down vote accepted

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
link|improve this answer
This is because it's simply not possible to write such a program for Windows. – JdeBP Aug 27 '11 at 11:51
I don’t see why not. It may not be (at least directly) possible with the provided command-prompt, but there’s nothing stopping one from easily creating a console program that provides the functionality. – Synetech Aug 27 '11 at 19:31
Wrong. There is something. I've already explained what it is at length. – JdeBP Aug 28 '11 at 0:13
feedback

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...

link|improve this answer
That is exactly how I am doing it right now. Still hoping for a better way... – mark Aug 21 '11 at 8:23
@mark well a better way to copy/paste from there is "quickedit mode", it's a must. – barlop Aug 23 '11 at 3:23
I have quick edit mode enabled, of course. – mark Aug 23 '11 at 9:02
feedback

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.

link|improve this answer
feedback

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>

link
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.