Skip to main content
More details
Source Link
coverflower
  • 113
  • 3
  • 15

How to redirect stdout and stderr in bash script with dialog boxes?

For a single script redirecting stdout and stderr to a file with this:

./myscript.sh 2>&1 | tee -a out_file

works fine. When I try to run the same way a script containing multiple dialogsdialog boxes created with dialog command (and calling other scripts)

./main.sh 2>&1 | tee -a out_file

the out_file contains unwanted characters due to the containing dialogsthese boxes. For example:

#!/bin/bash
# myscript.sh

dialog --title "Title" \
--msgbox "Message Box" \
30 120
date 

generates with:

$ ./myscript.sh 2>&1 | tee -a myscript.out

multiple lines similar to this one:

[36m[44m  [30m[40m[K[22;38H[39;49m(B[m[2;3H[30m[47mMessage Box[22;38H[39;49m(B[m

How can I get stdout and stderr without these characters (for main and all subsequent scripts)? That would be in the example the output of date. Nice to have would be what a user has entered in an inputbox.

How to redirect stdout and stderr in bash script with dialog?

For a single script redirecting stdout and stderr to a file with this:

./myscript.sh 2>&1 | tee -a out_file

works fine. When I try to run the same way a script containing multiple dialogs (and calling other scripts)

./main.sh 2>&1 | tee -a out_file

the out_file contains unwanted characters due to the containing dialogs. How can I get stdout and stderr without these characters (for main and all subsequent scripts)?

How to redirect stdout and stderr in bash script with dialog boxes?

For a single script redirecting stdout and stderr to a file with this:

./myscript.sh 2>&1 | tee -a out_file

works fine. When I try to run the same way a script containing multiple dialog boxes created with dialog command (and calling other scripts)

./main.sh 2>&1 | tee -a out_file

the out_file contains unwanted characters due to these boxes. For example:

#!/bin/bash
# myscript.sh

dialog --title "Title" \
--msgbox "Message Box" \
30 120
date 

generates with:

$ ./myscript.sh 2>&1 | tee -a myscript.out

multiple lines similar to this one:

[36m[44m  [30m[40m[K[22;38H[39;49m(B[m[2;3H[30m[47mMessage Box[22;38H[39;49m(B[m

How can I get stdout and stderr without these characters (for main and all subsequent scripts)? That would be in the example the output of date. Nice to have would be what a user has entered in an inputbox.

Source Link
coverflower
  • 113
  • 3
  • 15

How to redirect stdout and stderr in bash script with dialog?

For a single script redirecting stdout and stderr to a file with this:

./myscript.sh 2>&1 | tee -a out_file

works fine. When I try to run the same way a script containing multiple dialogs (and calling other scripts)

./main.sh 2>&1 | tee -a out_file

the out_file contains unwanted characters due to the containing dialogs. How can I get stdout and stderr without these characters (for main and all subsequent scripts)?