Re: how to know if I'm using xterm or gnome-terminal?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2/23/2010 2:38 PM, Germán A. Racca wrote:
> On Tue, 2010-02-23 at 20:23 +0000, James Wilkinson wrote:
>
>> Germán A. Racca wrote:
>>
>>> How to know if I'm using an xterm or a gnome-terminal from command line?
>>>
>>> The output of "echo $TERM" is "xterm" from both of them.
>>>
>>> How to know?
>>>
> I'm running a program called IRAF to work with astronomical images, and
> it needs to use the graphic capabilities of an xterm, not
> gnome-terminal. So, I'm trying to make a very simple script to start
> IRAF, but first I have to know if I'm on an xterm (so it enters directly
> to IRAF) or a gnome-terminal (in this case the script must open an xterm
> before).
>
> Germán.
>
What about something like this in your script?

     PARENTPID=$(ps -o ppid -p $PPID | tail -n1)
     ps u -p $PARENTPID | grep xterm && { echo "Yes!"; } || { echo "no"; }

The first line gets the parent of your script's parent process (so 
bash's parent). Then the second line prints out the information based on 
that pid, which is what you're testing against.

If there are more levels in between, this doesn't work the way it is, 
but you should be able to easily scale it to a loop which keeps going 
either until it hits an xterm process or hits init (as a last resort. 
Maybe there are better conditions you could figure out).

Justin Willmert
-- 
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines

[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux