Re: meed a memory kick how to test for X running or not

From: Lew Pitcher (Lew.Pitcher_at_td.com)
Date: 07/30/04


Date: Fri, 30 Jul 2004 15:35:31 -0400


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Michael Heiming wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> NotDashEscaped: You need GnuPG to verify this message
>
> In comp.unix.shell Michael Heiming <michael+USENET@www.heiming.de>
suggested:
>
>>In comp.unix.shell Juha Laiho <Juha.Laiho@iki.fi> suggested:
>>
>>>Michael Heiming <michael+USENET@www.heiming.de> said:
>>>
>>>>( tty | grep pts > /dev/null) && echo "X" || echo "VT"
>
>
>>>... and as an aside, that's quite a construct;
>>>subshell running a pipe, redirected to /dev/null, then a conditional
>>>expression based on the subshell exit value.
>
>
>>LOL..Yep, you are quite right, just a quick shot, nowhere near a
>>master piece of shell programming.;)
>
>
>>>How about:
>
>
>>>[[ $( tty ) == *pts* ]] && echo pts || echo non-pts
>
>
>>Looks a lot cleaner, anyway you couldn't haven't pointed that
>>out without my post in the fist place.
>>;)
>
>
> The only real problem with that line, it doesn't work for me at
> all. From some xterm on the box I'm sitting in front of:
>
> $ [[ $( tty ) == pts ]] && echo pts || echo non-pts
> non-pts
[snip]
> Or did I overlooked something?

Pardon my interruption, but it appears that you /did/ overlook something ;-)

The suggested commandline seems to be

  [[ $( tty ) == *pts* ]] && echo pts || echo non-pts

but you typed

  [[ $( tty ) == pts ]] && echo pts || echo non-pts

You seem to have missed the globbing around the 'pts' literal in the
initial test.

- --

Lew Pitcher, IT Consultant, Enterprise Application Architecture
Enterprise Technology Solutions, TD Bank Financial Group

(Opinions expressed here are my own, not my employer's)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)

iD8DBQFBCqMCagVFX4UWr64RAk8IAJ4wtXpUYIDibvAI9pWc36PYnCt5sACdEpwC
xrszSyqj9UFA3pIp7bcJlVM=
=1ZfQ
-----END PGP SIGNATURE-----



Relevant Pages


Quantcast