0

How can I save all the input(cin) and output(cout, cerr) from a program whose input is taken from file(using "<")? I would like the input and output to be in order(so each input is followed by corresponding output as if I were typing the input in myself).

I tried ">" to output everything to a file, but that only saves standard output(no input/cerr), and just plainly copying the command line output still only gives the output without the input(because of how "<" works).

Is there a way to write everything(output+input) to file in order?

EDIT: edited for clarity

EDIT2: I just realized that it's impossible to do what I'm trying to do since the console does not know anything about when the commands would actually be entered. I'll have to manually enter commands and use the "script" command to actually log all input/output.

1
  • myProg < in > out ; cat in out >> combined_out. Commented Apr 13, 2012 at 18:46

1 Answer 1

3

You need to add cerr to the stream

command > file 2&>1

This means put 2 (stderr) to 1 (stdout) as well.

Sign up to request clarification or add additional context in comments.

2 Comments

This only gives the output without the input though(remember, the input is also redirected from a file)
stdin is a separate stream and not affected by the combination: command < inputfile > outputfile 2&>1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.