Gentoo Archives: gentoo-user

From: Uwe Thiem <uwix@××××.na>
To: Gentoo User <gentoo-user@l.g.o>
Subject: Re: [gentoo-user] Test for X from cli
Date: Tue, 01 Aug 2006 19:50:31
Message-Id: 200608012041.41718.uwix@iway.na
In Reply to: [gentoo-user] Test for X from cli by "John J. Foster"
1 On 01 August 2006 20:20, 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 See this script by the name "strangename":
8
9 #! /bin/sh
10
11 ps ax | grep strangename
12
13
14 If run in a terminal under X it will output something like:#
15 20516 pts/3 R+ 0:00 grep strangename
16
17 Please note the "pts".
18
19 Run from a virtual text terminal, that will be something like "tty4".
20
21 Instead of actually displaying the output, you can analyse it within your
22 script.
23
24 Uwe
25
26 --
27 Mark Twain: I rather decline two drinks than a German adjective.
28 http://www.SysEx.com.na
29 --
30 gentoo-user@g.o mailing list

Replies

Subject Author
Re: [gentoo-user] Test for X from cli Rick van Hattem <Rick.van.Hattem@××××.nl>