Saving output *and commands* from Windows Command Prompt and/or Git-Bash

For an assignment, I need to run a few commands in the terminal and save the entire session - both the output and commands - to a text file. Piping the Command Prompt commands saves only the output; in a Linux terminal I'd use the "script" command, but git-bash cannot find this command.

2

1 Answer

Since script command is available for Linux. Windows Command Prompt does not have script command. Git-Bash is also modified and formatted form of Windows Command Prompt so it also does not have script command. To have it Login to Linux machine from Git-Bash and proceed as per instruction. So to use script command:

  1. Either Login to a Linux Machine and run the script command and then run the command you need to run.
  2. Or do a ssh login on to a remote Linux Machine from Git-Bash and proceed further.

If want to same behavior on Windows:

  1. Write equivalent batch script for windows command prompt. By default command prompt first echo the command and then its output unless you use @echo off at the first line of batch script.
  2. Find a windows version of script command if someone have taken the pain to write for you still the command run on Linux can not be fully available on windows.
2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like