Try this:
script -q -c 'module help null' /dev/null > aaa.txt
This works in a shell script (non-interactively) using
$ script --version
script (util-linux-ng 2.16)
You may also be able to use expect
.
Also see: Catching a direct redirect to /dev/tty.
More Related Contents:
- How to store standard error in a variable
- Bash script – store stderr in a variable [duplicate]
- What does 2>&1 mean here?
- In the shell, what does ” 2>&1 ” mean?
- How can I use a file in a command and redirect output to the same file without truncating it?
- How to redirect and append both standard output and standard error to a file with Bash
- How can I pipe stderr, and not stdout?
- Redirect stderr and stdout in Bash [duplicate]
- redirect COPY of stdout to log file from within bash script itself
- Bash how do you capture stderr to a variable? [duplicate]
- How to redirect both stdout and stderr to a file [duplicate]
- Shell redirection i/o order
- Send string to stdin
- Can colorized output be captured via shell redirect? [duplicate]
- Piping both stdout and stderr in bash?
- Capture both stdout and stderr in Bash [duplicate]
- Piping and Redirection
- What does ” 2>&1 ” mean?
- How to use > in an xargs command?
- Bash script error [: !=: unary operator expected
- How do I prompt a user for confirmation in bash script? [duplicate]
- bash set -e and i=0;let i++ do not agree
- How to use Bash to create a folder if it doesn’t already exist?
- How to properly nest Bash backticks
- How to insert a new line character after a fixed number of characters in a file
- How to add path with space in Bash variable
- What is more portable? echo -e or using printf?
- Bash If-statement to check If string is equal to one of several string literals [duplicate]
- How to delete rows from a csv file based on a list values from another file?
- ‘which’ vs ‘command -v’ in Bash [duplicate]