1 |
John J. Foster wrote: |
2 |
> Good afternoon, |
3 |
> |
4 |
> In a bash script, how can I test whether the script itself is being |
5 |
> run from a virtual terminal, or from an emulator like konsole within X? |
6 |
> |
7 |
> Thanks, |
8 |
> festus |
9 |
|
10 |
Hello, |
11 |
|
12 |
Here is yet another approach. |
13 |
So I would use the command "tty". |
14 |
|
15 |
======== |
16 |
danny@localhost ~ $ whatis tty |
17 |
tty (1) - print the file name of the terminal connected to standard input |
18 |
======== |
19 |
|
20 |
So the check could look something like this: |
21 |
|
22 |
#!/bin/sh |
23 |
for ttyX in /dev/tty*; |
24 |
do |
25 |
[ "`tty`" == "$ttyX" ] && { echo "no X" ; break ; } |
26 |
echo "X section" |
27 |
done |
28 |
|
29 |
|
30 |
|
31 |
-- |
32 |
Best regards, |
33 |
Daniel |
34 |
|
35 |
-- |
36 |
gentoo-user@g.o mailing list |