I am trying to redirect all output from bash (prompt, user input, results) to a file
Example:
/bin/bash > file.txt 2>&1
I thought that would work, but I'm not getting the prompt. Can anyone tell me what I'm doing wrong?
|
I am trying to redirect all output from bash (prompt, user input, results) to a file Example:
I thought that would work, but I'm not getting the prompt. Can anyone tell me what I'm doing wrong? |
||||
|
|
|
Bash outputs the prompt only in interactive mode. I.e. it is normally output to the terminal (/dev/tty on linux). That is neither /dev/stdout or /dev/stdin :) Now, I'm not sure but I can imagine that bash will allow limited interactive mode when there isn't a fully functional tty. In that case I'd expect the prompt to be written to stdout. I haven't tested that. Nice Proof Of Concept:
will just output 1..10 as if there wasn't redirection. Like the prompt, output is directly sent to the terminal (which will fail if there isn't one) HINT: if you wanted everything to be collected look at
|
|||||||
|
|
To trick
|
|||
|
|
|
The simplest way to do it would be
Bash will write everything to Notice that if you run the same thing without Oh yes, and the |
|||
|
|
|
The prompt is written to stderr as truss (on Solaris here) shows:
|
|||
|
|