LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-22-2011, 06:52 AM   #1
Joydeep Bakshi
Member
 
Registered: May 2007
Distribution: debian
Posts: 62

Rep: Reputation: 15
How can I check my environment ?


Hello,

I have written a tiny script for kernel compilation, which call menuconfig and then compile the kernel. It is working fine.
Now I like to test my environment and if it is shell menuconfig will be called and if X then xconfig will be called.
How can I check the environment then ?

Thanks
 
Old 07-22-2011, 08:19 AM   #2
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
try
Code:
if test -t 0 ;then
 
Old 07-22-2011, 08:31 AM   #3
Joydeep Bakshi
Member
 
Registered: May 2007
Distribution: debian
Posts: 62

Original Poster
Rep: Reputation: 15
Could you please explain a little ? What actually is it testing ?
 
Old 07-22-2011, 08:48 AM   #4
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
man test

Code:
     -t file_descriptor
                   True if the file whose file descriptor number is
                   file_descriptor is open and is associated with a terminal.
0 = stdin
1 = stdout
2 = stderr

it works for me, like so:
Code:
#!/bin/sh


do_it()
{
    find $HOME -name \*.core -exec rm {} \; -print
}


if test -t 0
then
    do_it
else
    2>&1 do_it | xmessage -file - -timeout 60
fi
so if I run xterm it prints, if i click the icon I get a pop-up window.
Is that what you meant?

Last edited by bigearsbilly; 07-22-2011 at 08:50 AM.
 
Old 07-22-2011, 08:56 AM   #5
Joydeep Bakshi
Member
 
Registered: May 2007
Distribution: debian
Posts: 62

Original Poster
Rep: Reputation: 15
Well my intention is little different.

Quote:
#need a test to check terminal or X
if terminal
then
make menuconfig
else
make xconfig
fi
 
Old 07-22-2011, 11:28 AM   #6
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Not fool-proof, but if $DISPLAY exists and has sane values, you could probably assume you can run xconfig. Your problem seems to become the more general question of whether there is a ready X server.

--- rod.

Last edited by theNbomr; 07-22-2011 at 11:29 AM.
 
Old 07-22-2011, 12:04 PM   #7
Joydeep Bakshi
Member
 
Registered: May 2007
Distribution: debian
Posts: 62

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by theNbomr View Post
Your problem seems to become the more general question of whether there is a ready X server.
But if I run the script from a virtual terminal, then even X running at different terminal; should call menuconfig
 
Old 07-22-2011, 12:23 PM   #8
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Quote:
Originally Posted by Joydeep Bakshi View Post
But if I run the script from a virtual terminal, then even X running at different terminal; should call menuconfig
$DISPLAY is not set in virtual terminals even if X is running.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] problem with 6.9glibc make -k check 2>&1 | tee glibc-check-log bhismnarayan Linux From Scratch 3 10-01-2010 08:51 AM
How can I check another user's environment? homer_3 Linux - Newbie 4 05-23-2008 03:44 PM
How to check English spell within a Chinese environment wuqso Linux - Software 0 01-06-2005 02:07 AM
Partition check, check double check Vincentius Linux - General 0 12-25-2004 05:47 AM
Boot disk; check. CD in drive; check. Doesn't work; check. Hal DamnSmallLinux 7 02-04-2004 02:10 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:26 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration