|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Is it possible for a bash script to test it it's not running in a
terminal and if that's the case, pop open an x-window of some sort (in linux) and redirect the output of the remaining commands in that script to the x-window? The test is easy enough: [ "$TERM" == "dumb" ] ....but I can't figure out how to redirect the output of the remaining script commands to an x-window. -- Dave Farrance |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On Thu, 24 Aug 2006 14:11:51 GMT, Dave Farrance
<DaveFarrance@OMiTTHiSyahooANDTHiS.co.uk> wrote: > Is it possible for a bash script to test it it's not running in a > terminal and if that's the case, pop open an x-window of some sort (in > linux) and redirect the output of the remaining commands in that script > to the x-window? > > The test is easy enough: [ "$TERM" == "dumb" ] > > ...but I can't figure out how to redirect the output of the remaining > script commands to an x-window. > To test whether the program is running under X, [ -n "$DISPLAY" ] Otherwise, you can redirect output to a file or pipe it to mail. { do_this; do_that; etc; } | xterm -hold -e cat If there is a lot of output, you can use less instead of cat, or use the -sl and -sb options to xterm. -- How do I type "for i in *.dvi do xdvi $i done" in a GUI? -- Discussion in comp.os.linux.misc on the intuitiveness of interfaces |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
Bill Marcum <bmarcum@iglou.com> wrote:
>On Thu, 24 Aug 2006 14:11:51 GMT, Dave Farrance wrote: >> Is it possible for a bash script to test it it's not running in a >> terminal and if that's the case, pop open an x-window of some sort (in >> linux) and redirect the output of the remaining commands in that script >> to the x-window? >> >To test whether the program is running under X, [ -n "$DISPLAY" ] >Otherwise, you can redirect output to a file or pipe it to mail. > >{ do_this; do_that; etc; } | xterm -hold -e cat >If there is a lot of output, you can use less instead of cat, or use the >-sl and -sb options to xterm. Looks good in principle, but doesn't work here for some reason. I tried: { echo 1; echo 2; } | xterm -hold -e cat .... in both Mandriva 2006 and Ubuntu 6.06 and although the xterm window opened, it remained completely blank. -- Dave Farrance |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
Dave Farrance wrote:
> Bill Marcum <bmarcum@iglou.com> wrote: > >> On Thu, 24 Aug 2006 14:11:51 GMT, Dave Farrance wrote: >>> Is it possible for a bash script to test it it's not running in a >>> terminal and if that's the case, pop open an x-window of some sort (in >>> linux) and redirect the output of the remaining commands in that script >>> to the x-window? >>> >> To test whether the program is running under X, [ -n "$DISPLAY" ] >> Otherwise, you can redirect output to a file or pipe it to mail. >> >> { do_this; do_that; etc; } | xterm -hold -e cat >> If there is a lot of output, you can use less instead of cat, or use the >> -sl and -sb options to xterm. > > Looks good in principle, but doesn't work here for some reason. I tried: > > { echo 1; echo 2; } | xterm -hold -e cat > > ... in both Mandriva 2006 and Ubuntu 6.06 and although the xterm window > opened, it remained completely blank. > mkfifo FIFO xterm -hold -e 'cat FIFO' & {commands generating data} > FIFO |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
Jon LaBadie <jxlabadie@axcxmx.org> wrote:
>Dave Farrance wrote: >> Looks good in principle, but doesn't work here for some reason. I tried: >> >> { echo 1; echo 2; } | xterm -hold -e cat >> >> ... in both Mandriva 2006 and Ubuntu 6.06 and although the xterm window >> opened, it remained completely blank. > >mkfifo FIFO >xterm -hold -e 'cat FIFO' & >{commands generating data} > FIFO Thanks. That's an improvement in that it works in Ubuntu 6.06, but not in Mandriva 2006. Maybe I should update the latter to the Mandriva 2007 beta anyway. -- Dave Farrance |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
On 2006-08-24, Dave Farrance wrote:
> Is it possible for a bash script to test it it's not running in a > terminal and if that's the case, pop open an x-window of some sort (in > linux) and redirect the output of the remaining commands in that script > to the x-window? > > The test is easy enough: [ "$TERM" == "dumb" ] > > ...but I can't figure out how to redirect the output of the remaining > script commands to an x-window. [ -t 0 ] || { xterm -e "$0" "$@"; exit; } printf "%s " "${*:-Enter name: }" read name -- Chris F.A. Johnson, author <http://cfaj.freeshell.org> Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress) ===== My code in this post, if any, assumes the POSIX locale ===== and is released under the GNU General Public Licence |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
"Chris F.A. Johnson" <cfajohnson@gmail.com> wrote:
>On 2006-08-24, Dave Farrance wrote: >> Is it possible for a bash script to test it it's not running in a >> terminal and if that's the case, pop open an x-window of some sort (in >> linux) and redirect the output of the remaining commands in that script >> to the x-window? >> >> The test is easy enough: [ "$TERM" == "dumb" ] >> >> ...but I can't figure out how to redirect the output of the remaining >> script commands to an x-window. > >[ -t 0 ] || { xterm -e "$0" "$@"; exit; } >printf "%s " "${*:-Enter name: }" >read name Thanks. That works fine. -- Dave Farrance |
|
![]() |
| Outils de la discussion | |
|
|